MirrorReflections with bump as surface shader?

I have successfully ported the wiki MirrorReflection2 shader from the wiki to a Surface shader, problem is i now want to add bump to the reflection… here’s what i have so far:

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 tex = tex2D (_MainTex, IN.uv_MainTex);
	fixed2 screenUV = IN.screenPos.xy / IN.screenPos.w;
	
	o.Albedo = tex.rgb;
	o.Normal = UnpackNormal (tex2D(_BumpMap, IN.uv_BumpMap));
	o.Emission = tex2D (_ReflectionTex, screenUV) *tex.a *_Color.a;
	
}

unfortunately the bump doesn’t affect reflections (eg. shadowed area are flat mirrors)
any ideas? thanks :slight_smile:

1 Like

bump? i just can’t get the bump to work with emissions :frowning:

here’s what it looks like with cubemaps vs my mirrorReflection shader

608776--21666--$Screen shot 2011-06-17 at 18.11.37.png
608776--21667--$Screen shot 2011-06-17 at 18.11.16.png

nevermind i got it…

if anyone’s interested, heres my shader:

Shader "FX/Mirror Reflection" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_BumpMap ("Normalmap", 2D) = "bump" {}
		
		_ReflAmount ("Reflection amount", float) = 0.5
		_ReflDistort ("Reflection distort", float) = 0.25
		_ReflectionTex ("Reflection", 2D) = "white" { TexGen ObjectLinear }
	}
	
	SubShader {
		Tags { "RenderType" = "Opaque" }
		CGPROGRAM
		#pragma surface surf Lambert
		//#pragma surface surf BlinnPhong
		
		struct Input {
			float2 uv_MainTex;
			float2 uv_BumpMap;
			float4 screenPos;
		};	
		
		uniform fixed4 _Color;
		uniform sampler2D _MainTex;
		uniform sampler2D _BumpMap;
		uniform float _ReflAmount;
		uniform float _ReflDistort;
		uniform sampler2D _ReflectionTex;
		
		void surf (Input IN, inout SurfaceOutput o) {
			
			fixed4 tex = tex2D (_MainTex, IN.uv_MainTex);
			fixed3 nor = UnpackNormal (tex2D(_BumpMap, IN.uv_BumpMap));
			
			fixed2 screenUV = (IN.screenPos.xy) / (IN.screenPos.w);
			screenUV.xy += nor *_ReflDistort;
			
			fixed4 refl = tex2D (_ReflectionTex, screenUV);
			
			o.Albedo = tex.rgb *_Color.rgb;
			o.Normal = nor.rgb;
			o.Emission = refl *_ReflAmount *tex.a;
			o.Specular = _Color.a;
			o.Gloss = tex.a;
			o.Alpha = tex.a;
			
		}
		ENDCG
	}
	
	FallBack "Diffuse"
}
2 Likes

Hello, I am also I of Padua in Italy, have you tried strumpy shader editor to achieve this effect?

I’ve been crying out for a shader like this! Shiny floors, great. This has all the features one could hope for, that would take me half a year to work out how to do. THANKYOU :slight_smile:

No because i find it easier to code directly in surface shader/CG…

Glad to be of help :slight_smile:

Hi Steva…u know what…this what i looking for…gracias my friend… :slight_smile:

Thanks for sharing Steva but will this work with MirrorReflection3 in Unity5?