Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "FX/FragCubemap"
- {
- Properties
- {
- _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
- _EnvTex ("CubeMap", CUBE) = "black" {}
- _MainTint ("Diffuse Tint", Color) = (1,1,1,1)
- _ReflAmount ("Reflection Amount", Range(0.01, 1)) = 0.5
- }
- SubShader
- {
- Tags { "RenderType"="Opaque" "LightMode"="ForwardBase"}
- LOD 200
- CGINCLUDE
- #include "UnityCG.cginc"
- sampler2D _MainTex;
- fixed4 _MainTex_ST;
- samplerCUBE _EnvTex;
- #ifndef LIGHTMAP_OFF
- fixed4 unity_LightmapST;
- sampler2D unity_Lightmap;
- #endif
- fixed4 _MainTint;
- fixed _ReflAmount;
- struct v2f
- {
- fixed4 pos : SV_POSITION;
- fixed2 uv : TEXCOORD0;
- #ifndef LIGHTMAP_OFF
- fixed2 uvLM : TEXCOORD1;
- #endif
- fixed3 refl : TEXCOORD2;
- };
- ENDCG
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma fragmentoption ARB_precision_hint_fastest
- v2f vert (appdata_full v)
- {
- v2f o;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
- o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
- #ifndef LIGHTMAP_OFF
- o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
- #endif
- fixed3 worldNormal = mul((fixed3x3)_Object2World, v.normal);
- fixed3 worldViewDir = normalize(WorldSpaceViewDir(v.vertex));
- o.refl = reflect(normalize(-worldViewDir.xyz), normalize(worldNormal));
- return o;
- }
- fixed4 frag (v2f i) : COLOR
- {
- fixed4 rFactor = texCUBE(_EnvTex, (i.refl)) * _ReflAmount;
- fixed4 tex = tex2D(_MainTex, i.uv.xy) * _MainTint;
- tex += rFactor * tex.a;
- #ifndef LIGHTMAP_OFF
- fixed3 lm = DecodeLightmap (tex2D(unity_Lightmap, i.uvLM));
- tex.xyz *= lm;
- #endif
- return tex;
- }
- ENDCG
- }
- }
- FallBack "MADFINGER/Environment/Cube env map (Supports Lightmap)"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement