- Home /
Question by
Noxury · Mar 25, 2016 at 05:27 PM ·
shadercullingbackfaceunlit transparent
Backface Culling Off for Unlit Transparent Shader
Hello,
I have an Unlit Transparent Shader which I have found on this site.
Now I want to add an backface culling off property to render a mesh on both sides:
Shader "Unlit/AlphaSelfIllum" {
Properties {
_Color ("Main Color (A=Opacity)", Color) = (1,1,1,1)
_MainTex ("Base (A=Opacity)", 2D) = ""
}
Category {
Tags {"Queue"="Transparent" "IgnoreProjector"="True"}
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
SubShader {Pass {
Cull Off
GLSLPROGRAM
varying mediump vec2 uv;
#ifdef VERTEX
uniform mediump vec4 _MainTex_ST;
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex;
uniform lowp vec4 _Color;
void main() {
gl_FragColor = texture2D(_MainTex, uv) * _Color;
}
#endif
ENDGLSL
}}
SubShader {Pass {
SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]}
}}
}
}
But Cull Off has no effect. Any suggestions?
Comment
Answer by SquareR00T · Aug 06, 2017 at 03:09 PM
place the Cull Off tag just below the ZWrite Off, like so:
Shader "Unlit/AlphaSelfIllum" {
Properties {
_Color ("Main Color (A=Opacity)", Color) = (1,1,1,1)
_MainTex ("Base (A=Opacity)", 2D) = ""
}
Category {
Tags {"Queue"="Transparent" "IgnoreProjector"="True"}
ZWrite Off
Cull Off
Blend SrcAlpha OneMinusSrcAlpha
SubShader {
Pass {
GLSLPROGRAM
varying mediump vec2 uv;
#ifdef VERTEX
uniform mediump vec4 _MainTex_ST;
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex;
uniform lowp vec4 _Color;
void main() {
gl_FragColor = texture2D(_MainTex, uv) * _Color;
}
#endif
ENDGLSL
}
}
SubShader {
Pass {
SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]}
}
}
}
}
Your answer
Follow this Question
Related Questions
Disable backface culling or double geometry? 0 Answers
Problem with flipping ! 0 Answers
Culling Shader 1 Answer
Shaders: Turn culling on/off by keyword 0 Answers