Quantcast
Channel: Answers for "Mirror + Shadows shader."
Viewing all articles
Browse latest Browse all 10

Answer by Gunder

$
0
0

I got it, only modify the shader:

Shader "FX/Mirror Reflection" { 
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
	_MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} 
	_ReflectionTex ("Reflection", 2D) = "_Skybox" { TexGen ObjectLinear }
}
SubShader {
	LOD 200
	Tags { "RenderType"="Opaque" }
	Pass { 
		Name "BASE"
		Tags {"LightMode" = "Always"}
		CGPROGRAM
		#pragma vertex vert
		#pragma fragment frag
		#pragma fragmentoption ARB_fog_exp2
		#pragma fragmentoption ARB_precision_hint_fastest
		#include "UnityCG.cginc"

		struct v2f {
			V2F_POS_FOG;
			float2 uv : TEXCOORD0;
			float3 uv2 : TEXCOORD1;
		};

		uniform float4 _MainTex_ST;
		uniform float3x3 _ProjMatrix;

		v2f vert(appdata_tan v)
		{
			v2f o;
			PositionFog( v.vertex, o.pos, o.fog );
			float3 viewDir = ObjSpaceViewDir( v.vertex );
			o.uv2 = mul( _ProjMatrix, viewDir );
			o.uv = TRANSFORM_TEX(v.texcoord,_MainTex);
			return o; 
		}

		uniform sampler2D _MainTex;
		uniform sampler2D _ReflectionTex;
		uniform float4 _ReflectColor;

		half4 frag (v2f i) : COLOR
		{
			half4 texcol = tex2D (_MainTex, i.uv);
			half4 reflcol = tex2Dproj( _ReflectionTex, i.uv2 ) * 2;
			reflcol *= _ReflectColor.a;
			return reflcol * _ReflectColor;
		} 
		ENDCG
	}

	UsePass "Diffuse/PPL"
} 
FallBack "Reflective/VertexLit", 1

}


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>