Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Shader Error due to dynamic conditional 'if' blocks

$
0
0
I searched online and could find some similar problems, but none of them fixed my problem. It is an error that ONLY occurs when building the game. When playing from the editor no errors are seen and the shader works as intended. The error: > Shader error in 'Custom/Outline_2DSprite': texld/texldb/texldp/dsx/dsy instructions with r# as source cannot be used inside dynamic conditional 'if' blocks, dynamic conditional subroutine calls, or loop/rep with break*. at line 35 (on d3d9) The important bit of the shader: CGPROGRAM #pragma surface surf Lambert alpha struct Input { float2 uv_MainTex; fixed4 color : COLOR; }; sampler2D _MainTex; float _OutLineSpreadX; float _OutLineSpreadY; float4 _Color; void surf(Input IN, inout SurfaceOutput o) { fixed4 tex1 = tex2D(_MainTex, IN.uv_MainTex+float2(_OutLineSpreadX,0.0)); fixed4 tex2 = tex2D(_MainTex, IN.uv_MainTex-float2(_OutLineSpreadX,0.0)); fixed4 tex3 = tex2D(_MainTex, IN.uv_MainTex+float2(0.0,_OutLineSpreadY)); fixed4 tex4 = tex2D(_MainTex, IN.uv_MainTex-float2(0.0,_OutLineSpreadY)); fixed4 TempColor = tex1 + tex2; TempColor = TempColor + tex3 + tex4; if(TempColor.a > 0.1){ TempColor.a = 1; } fixed4 AlphaColor = fixed4(TempColor.a,TempColor.a,TempColor.a,TempColor.a); fixed4 mainColor = AlphaColor * _Color.rgba; fixed4 addcolor = tex2D(_MainTex, IN.uv_MainTex) * IN.color; if(addcolor.a > 0.95){ mainColor = addcolor; } o.Albedo = mainColor.rgb; o.Alpha = mainColor.a; } ENDCG It has to do with the fact that I can't use tex2D inside an if statement, but can't seem to fix it.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>