Inside Visible Transparent Unlit Unity Shader for making simple light independent material



Sometimes we need a material for some objects that is not going to be affected by any light, for example just like making LCD screen of a turned on TV. We can apply this kind of material to the LCD plane of that object, so no matter how the lighting is in the scene, the LCD is still visible.

This is a shader script you can use in your Unity project and apply it any object.

By default I made it “inside visible”, I mean when you use it, by default only the inside side of your mesh will be visible. Originally I used it to make a spherical dome as a sky dome in my project. So if you don’t need it to be visible inside (if you want to make it visible outside), just comment the line 12 “Cull front”, that’s all.

Here is the shader script:

Shader "TransparentUnlit" {
 
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
	Cull front 
 
    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]}
    }}
}
 
}
Some inside visible objects…
loading...

Leave a Reply

Your email address will not be published.