Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "FX/MatcapBumpedLM"
- {
- Properties
- {
- _MainTex ("Base (RGB)", 2D) = "white" {}
- _BumpMap ("Bumpmap (RGB)", 2D) = "bump" {}
- _MatCap ("MatCap (RGB)", 2D) = "white" {}
- }
- 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 sampler2D _BumpMap;
- uniform fixed4 _BumpMap_ST;
- #ifndef LIGHTMAP_OFF
- uniform fixed4 unity_LightmapST;
- uniform sampler2D unity_Lightmap;
- #endif
- struct v2f
- {
- fixed4 pos : SV_POSITION;
- fixed2 uv : TEXCOORD0;
- fixed2 uv_bump : TEXCOORD1;
- #ifndef LIGHTMAP_OFF
- fixed2 uvLM : TEXCOORD2;
- #endif
- fixed3 TtoV0 : TEXCOORD4;
- fixed3 TtoV1 : TEXCOORD5;
- };
- v2f vert (appdata_full v)
- {
- v2f o;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
- o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
- o.uv_bump = TRANSFORM_TEX(v.texcoord, _BumpMap);
- #ifndef LIGHTMAP_OFF
- o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
- #endif
- TANGENT_SPACE_ROTATION;
- o.TtoV0 = mul(rotation, UNITY_MATRIX_IT_MV[0].xyz);
- o.TtoV1 = mul(rotation, UNITY_MATRIX_IT_MV[1].xyz);
- return o;
- }
- float4 frag (v2f i) : COLOR
- {
- fixed4 tex = tex2D(_MainTex, i.uv.xy);
- fixed3 normals = UnpackNormal(tex2D(_BumpMap, i.uv_bump));
- fixed2 capCoord = half2(dot(i.TtoV0, normals), dot(i.TtoV1, normals));
- fixed4 matcapLookup = tex2D(_MatCap, capCoord * 0.5 + 0.5);
- matcapLookup.a = 1.0;
- tex *= matcapLookup * 2.0;
- #ifndef LIGHTMAP_OFF
- fixed3 lm = DecodeLightmap (tex2D(unity_Lightmap, i.uvLM.xy));
- tex.xyz *= lm;
- #endif
- return tex;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement