- Home /
Mirror reflection intensity
I'm using mirror material (shader+script). There is a way to control reflection intensity with a map or a number value (best way)? I try to modify shader without result... Thanks. Somebody suggest me to add _Color parameter in the first pass. I try without results...
Shader "FX/Control Mirror Reflection" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_ReflectionTex ("Reflection", 2D) = "white" { TexGen ObjectLinear }
_Color ("Color Tint", Color) = (1,1,1,1)
}
// two texture cards: full thing
Subshader {
Color [_Color]
Pass {
SetTexture[_MainTex]
{
constantColor [_Color]
Combine texture * primary, texture * constant
}
SetTexture[_ReflectionTex] { matrix [_ProjMatrix] combine texture * previous }
}
}
// fallback: just main texture
Subshader {
Pass {
SetTexture [_MainTex] { combine texture }
}
}
}
Answer by Waz · Jul 13, 2011 at 10:20 AM
I'm not familiar with that shader, but the normal way to control reflection intensity is with that tint color - black for no reflection, white for full reflection. In addition, the base texture (sometimes in combination with a main color) controls the diffuse color of the mirror - a perfect mirror is black and a reflective cue-ball is white.
You may find that these two things are reversed - try with different colored textures also.
The FX/Water shader controls the reflectivity via the Fresnel parameter, since the reflectivity changes depending on the viewing angle.
Answer by benfattino · Jul 13, 2011 at 10:39 AM
Thanks for answer. I try different combination with color parameter, but no result for reflection. It is always 100%... I will try again... I see that FX/water built-in shader don't have parameter that reduce reflection...
I think you meant this as a Comment. You've posted it as an Answer, which makes your question look well-answered.
Answer by ShaneTheVeryTall · May 01, 2013 at 07:28 PM
I was having a similar need, and after reading the shader docs and not understanding much, I started just trying some different methods of combining textures. Somehow (with a ton of luck) I was able to arrive at a desirable result:
Shader "FX/Mirror Reflection" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_ReflectionTex ("Reflection", 2D) = "white" { TexGen ObjectLinear }
//_Color ("Color Tint", Color) = (1,1,1,1)
}
// two texture cards: full thing
Subshader {
Pass {
SetTexture[_MainTex] { combine texture }
SetTexture[_ReflectionTex] {
matrix [_ProjMatrix]
constantColor (.25,.25,.25,.25)
combine texture lerp(constant) previous
}
}
}
// fallback: just main texture
Subshader {
Pass {
SetTexture [_MainTex] { combine texture }
}
}
}
Changing the "constantColor" values to a higher amount will produce a stronger reflection. I was going for polished marble in this case, and it's pretty close at .25. It would be nice to have a slider in the editor to control this, but I'm a NOOOOOB and this is my first edited shader. :)