Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Hidden/ThermalVisionImageEffect"
- {
- Properties
- {
- _Matcap("Texture", 2D) = "white" {}
- [HideInInspector]_MainTex("Texture", 2D) = "white"{}
- _Opacity("Normals Opacity", Range(0,2)) = 0.4
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- float4 pos : TEXCOORD1;
- };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- o.pos = v.vertex;
- return o;
- }
- float _Opacity;
- sampler2D _CameraDepthNormalsTexture;
- float4 GetPixelValue(in float2 uv) {
- half3 normal;
- float depth;
- DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture, uv), depth, normal);
- return fixed4(normal, depth);
- }
- sampler2D _Matcap, _MainTex;
- fixed4 frag (v2f i) : SV_Target
- {
- fixed4 normals = GetPixelValue(i.uv);
- fixed4 color = tex2D(_MainTex, i.uv );
- float2 cap = normals.xy * 0.5 + 0.5;
- fixed4 col = tex2D(_Matcap, cap * _Opacity);
- return color + col;
- }
- ENDCG
- }
- }
- }
Add Comment
Please, Sign In to add comment