Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "FX/MatcapDiffuseLP"
- {
- Properties
- {
- _MainTex ("Base (RGB)", 2D) = "white" {}
- _MatCap ("MatCap (RGB)", 2D) = "white" {}
- _LPScale ("Light Probe Influence", float) = 1
- }
- Subshader
- {
- Tags { "RenderType"="Opaque" "BW"="TrueProbes"}
- Fog { Mode Off }
- Pass
- {
- Name "BASE"
- Tags { "LightMode" = "ForwardBase" }
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma fragmentoption ARB_precision_hint_fastest
- #pragma multi_compile LIGHTMAP_ON LIGHTMAP_OFF
- #include "UnityCG.cginc"
- uniform sampler2D _MatCap;
- uniform sampler2D _MainTex;
- uniform fixed4 _MainTex_ST;
- uniform fixed _LPScale;
- struct v2f
- {
- fixed4 pos : SV_POSITION;
- fixed2 uv : TEXCOORD0;
- fixed3 SHLighting : TEXCOORD2;
- fixed2 cap : TEXCOORD3;
- };
- v2f vert (appdata_full v)
- {
- v2f o;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
- o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
- fixed3 worldNormal = mul((fixed3x3)_Object2World, SCALED_NORMAL);
- fixed3 shl = ShadeSH9(fixed4(worldNormal, 1.0));
- o.SHLighting = shl * _LPScale;
- fixed2 capCoord;
- capCoord.x = dot(UNITY_MATRIX_IT_MV[0].xyz, v.normal);
- capCoord.y = dot(UNITY_MATRIX_IT_MV[1].xyz, v.normal);
- o.cap = capCoord * 0.5 + 0.5;
- return o;
- }
- float4 frag (v2f i) : COLOR
- {
- fixed4 tex = tex2D(_MainTex, i.uv.xy);
- fixed4 matcapLookup = tex2D(_MatCap, i.cap);
- matcapLookup.a = 1.0;
- tex *= matcapLookup * 2.0;
- tex.xyz *= i.SHLighting;
- return tex;
- }
- ENDCG
- }
- }
- FallBack "Mobile/Diffuse"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement