- Home /
Shader Not Blending Textures on Mobile
Hey all, I was just wondering if anyone had any idea why this shader doesn't work for mobile. The specific line that has problems is : col = lerp(col, c, 0.5);
Whenever it is set to 0 or 1 it will work, however any values in between don't seem to function properly and give me a pink terrain with the error "no subshaders can run on this graphics card"
I am attempting to write the shader for the Android platform at the moment. I haven't ever really done shader programming, so I apologize if it looks horrid.
Shader "Fog Of War/Terrain" {
Properties {
_FOWTex ("Detail", 2D) = "gray" {}
// Textures
_Control ("Control (RGBA)", 2D) = "white" {}
_Splat3 ("Layer 3 (A)", 2D) = "white" {}
_Splat2 ("Layer 2 (B)", 2D) = "white" {}
_Splat1 ("Layer 1 (G)", 2D) = "white" {}
_Splat0 ("Layer 0 (R)", 2D) = "white" {}
}
SubShader {
Tags {
"RenderType"="Opaque"
"Queue" = "Geometry-100"
"SplatCount" = "4"
}
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
#include "UnityCG.cginc"
struct Input {
float2 uv_FOWTex;
float2 uv_Control : TEXCOORD0;
float2 uv_Splat0 : TEXCOORD1;
float2 uv_Splat1 : TEXCOORD2;
float2 uv_Splat2 : TEXCOORD3;
float2 uv_Splat3 : TEXCOORD4;
};
sampler2D _FOWTex;
sampler2D _Control;
sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
void surf (Input IN, inout SurfaceOutput o) {
fixed4 splat_control = tex2D (_Control, IN.uv_Control).rgba;
float4 col;
float4 c;
col = splat_control.r * tex2D (_Splat0, IN.uv_Splat0);
col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1);
col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2);
col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3);
c = tex2D (_FOWTex, IN.uv_FOWTex).aaaa;
col = lerp(col, c, 0.5);
o.Albedo = col;
o.Alpha = 0.0;
}
ENDCG
}
Dependency "AddPassShader" = "MyShaders/Terrain/Editor/AddPass"
Dependency "BaseMapShader" = "MyShaders/Terrain/Editor/BaseMap"
}
Answer by ReiBM · Jun 07, 2014 at 03:19 PM
I found that after modifying the above
pragma surface surf Lambert
To :
pragma surface surf Lambert decal:add decal:blend alpha
The script works properly.
Your answer
Follow this Question
Related Questions
How to force the compilation of a shader in Unity? 5 Answers
Multiple tex2D commands in fragment shader needed, is there a workaround? 0 Answers
Custom ambient lighting color in a Cg shader 2 Answers
Can I read `CGPROGRAM` `#define` constants in `.cs` at runtime? 0 Answers
How to use array in cg shader 1 Answer