Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by flashtech · Apr 17, 2010 at 08:31 AM · shadergraphicswaterreflection

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image duck ♦♦ · Apr 17, 2010 at 03:06 PM 1
Share

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!

4 Replies

· Add your reply
  • Sort: 
avatar image
7

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 :-)

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image flashtech · Apr 17, 2010 at 03:09 PM 0
Share

This is Great, but i find on the Linenumber position not that waht you Writing here ????

avatar image flashtech · Apr 17, 2010 at 03:13 PM 0
Share

i find only This:

Line 10: Reflective = 1, Line 99: GL.SetRevertBackfacing (false); Line 145: }

and now?

avatar image duck ♦♦ · Apr 17, 2010 at 03:48 PM 0
Share

You're looking in the wrong file. That's "Water.cs" when you should be looking in "FX-Water.shader"

avatar image flashtech · Apr 17, 2010 at 03:54 PM 0
Share

O$$anonymous$$ Thank you very musch $$anonymous$$an ;-)

avatar image Kourosh · Oct 14, 2010 at 11:43 AM 0
Share

How about refraction is it also possible to make a slider for that?thanks.

avatar image Namey5 Kourosh · Jan 04, 2016 at 05:25 AM 0
Share

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).

avatar image
0

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...

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image flashtech · Apr 17, 2010 at 10:21 AM 0
Share

No i use a Plane oder the Terrain!

The use FX-Water (pro) but the Reflection ist too stronge. I want make this lower.

avatar image flashtech · Apr 17, 2010 at 10:21 AM 0
Share

Sorry Plane over the Terrain ;-)

avatar image flashtech · Apr 17, 2010 at 10:22 AM 0
Share

there i can walk on ;-)

avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Comatose · Nov 02, 2011 at 02:16 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Material doesn't have a color property '_Color' 4 Answers

Hungry Shark Evolution Water? 0 Answers

How do I mask game objects outside of volumetric area 1 Answer

can i have reflections on a self illuminated bumped diffuse object ? 3 Answers

How to control the FarClipPlane of a reflection camera in Unity3d (4.3f1) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges