- Home /
How can I Control the Strength of the Reflection in the Pro FX Water Shader
Hey!
I am using a Plane with my Terrain, which uses the FX-Water (pro), but the Reflection is too strong. I want make this lower.
how does it work?
In other words,
How can I fade the reflection.
Thank you
EDIT: I changed the title and tags and body to better reflect intent of question (based on your further clarification in the comments below). Please let me know if this seems to more closely match what you intended, or if I have got the wrong idea!
Answer by duck · Apr 17, 2010 at 02:33 PM
Ok it sounds like you want to reduce the strength of the reflection when using the Pro water shader.
It seems that there isn't a setting to do this with the water controls - the strength of the reflection is actually controlled by the alpha values in the "Reflective Colour" texture gradiant, which makes it a little awkward to adjust.
It is possible to add a simple slider, so that you can use this instead of editing the alpha channel of that texture. To do this, you'll need to make 3 simple edits to the water shader source file.
You need to open up the file called "FX-Water.shader" in a text editor. This file should be in your project assets folder, in "Pro Standard Assets/Water/Sources". (note: not "FX-Water simple.shader").
Once you have it open, first, add a line, underneath line 10:
line 10: _ReflectiveColor ("Reflective color (RGB) fresnel (A) ", 2D) = "" {}
Add This-> _ReflectionStrength ("Reflection strength", Range(0.0,1.0)) = 0.5
Next, add a line under what is now line 96:
line 96: sampler2D _ReflectionTex;
Add This-> uniform float _ReflectionStrength;
Next, delete the lines that are currently directly above and below line 100:
before:
delete-> 99: #if defined WATER_REFLECTIVE || defined WATER_SIMPLE
100: sampler2D _ReflectiveColor;
delete-> 101: #endif
after:
99: sampler2D _ReflectiveColor;
Finally, change the block of code from lines 138-147 from:
original:
#ifdef WATER_REFRACTIVE half fresnel = tex2D( _Fresnel, float2(fresnelFac,fresnelFac) ).a; color = lerp( refr, refl, fresnel ); #endif
ifdef WATER_REFLECTIVE
alf4 water = tex2D( _ReflectiveColor, float2(fresnelFac,fresnelFac) ); color.rgb = lerp( water.rgb, refl.rgb, water.a ); color.a = refl.a * water.a; #endif
to this:
#ifdef WATER_REFRACTIVE half fresnel = tex2D( _Fresnel, float2(fresnelFac,fresnelFac) ).a; half4 water = tex2D( _ReflectiveColor, float2(fresnelFac,fresnelFac) ); color.rgb = lerp( water.rgb, refl.rgb, _ReflectionStrength ); color = lerp( refr, color, fresnel ); #endif
ifdef WATER_REFLECTIVE
alf4 water = tex2D( _ReflectiveColor, float2(fresnelFac,fresnelFac) ); color.rgb = lerp( water.rgb, refl.rgb, _ReflectionStrength ); color.a = refl.a * water.a; #endif
Now, save & close the shader file, and go back to Unity. You should now find that if you select your water, and scroll in the inspector down to the shader, there's a new slider called "Reflection Strength". You can adjust this from 0-1, which takes you from no reflection, all the way to the surface being 100% opaque reflection!
enjoy :-)
This is Great, but i find on the Linenumber position not that waht you Writing here ????
i find only This:
Line 10: Reflective = 1, Line 99: GL.SetRevertBackfacing (false); Line 145: }
and now?
You're looking in the wrong file. That's "Water.cs" when you should be looking in "FX-Water.shader"
O$$anonymous$$ Thank you very musch $$anonymous$$an ;-)
How about refraction is it also possible to make a slider for that?thanks.
Both the reflection and refraction follow a similar concept. All you would need to do is add another Range (0,1), and simply multiply the refraction by the range. There should be a variable called something along the line of "refr", as a float4/half4. Simply multiply this whole step by the refraction power variable you added earlier (which can be done following the same steps as the reflection power).
Answer by StephanK · Apr 17, 2010 at 08:54 AM
If you are using physics, you can adjust the physics materials of your colliding objects and reduce their bouncyness. Otherwise we could use some more info to help you...
No i use a Plane oder the Terrain!
The use FX-Water (pro) but the Reflection ist too stronge. I want make this lower.
Answer by jmsosullivan · Apr 30, 2011 at 01:02 PM
You don't need to change the water shader to adjust the amount of relfection. You can create your own fresnel texture that does the same thing.
In photoshop, select File -> New. Set the Width to 256 Pixels, Height to 32 Pixels. Set Background Contents to Transparent. Select OK.
Now, select the Brush Tool, and adjust its Size so that it covers the entire image.
Now, what adjusts the amount of reflection is the Opacity. 100% is totally reflective. 0% is no reflection. I find that about 15% gives a nice balance. But try it out for yourself!
Save it as a PSD file and put it into your assets folder. Then use it as the fresnel texture in the Water Shader.
Answer by Comatose · Oct 30, 2011 at 11:36 PM
Does anyone know how to change this for unity pro 3.0's Water4 Shader?
Never $$anonymous$$d, I solved the issue to remove it in Water4 here: http://answers.unity3d.com/questions/180988/can-you-remove-reflection-from-unity-pro-water.html
Your answer
Follow this Question
Related Questions
How to control the FarClipPlane of a reflection camera in Unity3d (4.3f1) 1 Answer
unity basic - island water (from the demo) - adjusting alpha 1 Answer
Flickering/Bright sparkeling with Planar Reflection Probe and Trees (HDRP) 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers