123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- Shader "Unlit/NormalOverlay"
- {
- Properties
- {
- _Transparency ("Transparency", Range(0, 1)) = 0.5
- }
- // URP SubShader
- SubShader
- {
- PackageRequirements
- {
- "com.unity.render-pipelines.universal"
- }
- Blend SrcAlpha OneMinusSrcAlpha
- Tags
- {
- "Queue" = "AlphaTest"
- "RenderType" = "Transparent"
- "ForceNoShadowCasting" = "True"
- "RenderPipeline" = "UniversalPipeline"
- }
- Pass
- {
- ZTest LEqual
- ZWrite On
- Lighting Off
- LOD 100
- Tags
- {
- "LightMode" = "UniversalForward"
- }
- HLSLPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
- struct appdata
- {
- float3 position : POSITION;
- float3 normal : NORMAL;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
- struct v2f
- {
- float4 position : SV_POSITION;
- half3 worldNormal : TEXCOORD0;
- UNITY_VERTEX_OUTPUT_STEREO
- };
- struct fragment_output
- {
- half4 color : SV_Target;
- };
- v2f vert (appdata v)
- {
- v2f o;
- UNITY_SETUP_INSTANCE_ID(v);
- ZERO_INITIALIZE(v2f, o);
- UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
- o.position = TransformObjectToHClip(v.position);
- o.worldNormal = TransformObjectToWorldNormal(v.normal);
- return o;
- }
- float _Transparency;
- fragment_output frag (v2f i)
- {
- UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
- fragment_output o;
- o.color.xyz = i.worldNormal * 0.5f + 0.5f;
- o.color.w = _Transparency;
- return o;
- }
- ENDHLSL
- }
- }
- // Built-in Render Pipeline SubShader
- SubShader
- {
- Blend SrcAlpha OneMinusSrcAlpha
- Tags
- {
- "Queue" = "AlphaTest"
- "RenderType" = "Transparent"
- "ForceNoShadowCasting" = "True"
- }
- Pass
- {
- ZTest LEqual
- ZWrite On
- Lighting Off
- LOD 100
- Tags
- {
- "LightMode" = "Always"
- }
- HLSLPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- struct appdata
- {
- float3 position : POSITION;
- float3 normal : NORMAL;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
- struct v2f
- {
- float4 position : SV_POSITION;
- half3 worldNormal : TEXCOORD0;
- UNITY_VERTEX_OUTPUT_STEREO
- };
- struct fragment_output
- {
- half4 color : SV_Target;
- };
- v2f vert (appdata v)
- {
- v2f o;
- UNITY_SETUP_INSTANCE_ID(v);
- UNITY_INITIALIZE_OUTPUT(v2f, o);
- UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
- o.position = UnityObjectToClipPos(v.position);
- o.worldNormal = UnityObjectToWorldNormal(v.normal);
- return o;
- }
- float _Transparency;
- fragment_output frag (v2f i)
- {
- UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
- fragment_output o;
- o.color.xyz = i.worldNormal * 0.5f + 0.5f;
- o.color.w = _Transparency;
- return o;
- }
- ENDHLSL
- }
- }
- Fallback Off
- }
|