- Home /
how to add bumpmap to MirrorReflection as surface shader
Hi,
i have rewritten the MirrorReflection2 shader as a surface shader, but i can't figure out how to add bumpmap distortion to the reflection... Here's my surface code so far:
void surf (Input IN, inout SurfaceOutput o) {
fixed2 screenUV = (IN.screenPos.xy) / (IN.screenPos.w);
fixed3 nor = UnpackNormal (tex2D(_BumpMap, IN.uv_BumpMap));
fixed4 tex = tex2D (_MainTex, IN.uv_MainTex);
fixed4 refl = tex2D (_ReflectionTex, screenUV);
o.Albedo = tex.rgb *_Color.rgb;
o.Normal = nor.rgb;
o.Emission = refl.rgb;
}
i think i should use something like WorldReflectionVector to get the normals and then apply reflections, but i hane no idea how to do this in a surface shader... any idea?
Answer by steva · Jun 21, 2011 at 03:32 PM
oh god it was so simple! just add:
screenUV.xy += nor *_ReflDistort;
where _ReflDistort is the amount of desired distortion...
Your answer
Follow this Question
Related Questions
Coloured specularity mapping? 1 Answer
Using TEXCOORD1 in surface shader 2 Answers
uv not being passed through from vertex to surface shader 1 Answer
What is the best way to create realistic surfing waves? 0 Answers
flip shader UV reading on ios 1 Answer