How to modify water shaders

Home Forums AR Sandbox Forum How to modify water shaders


Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #112869

    Hello there!
    I found out you can change the water colour in the /shaders/SurfaceAddWaterColor.fs file.
    There is a variable called vec4 WaterColor (Pretty straight forward). By modifying is value (better place two “/”s before the original variable, copy the old one and modify it in case you need a backup).
    And I tinkered with that variable, making a few new ones. But I don’t really know how it works. It has four arguments (I think that’s how they are called) and by modifying them you modify the colour of the water.
    By trying and testing I found out (I may be wrong) that the first two give the value for one color of the water and the other two for the second lolor, like the color of the water reflecting sunlight.
    But I don’t know how to give the water an exact colour using that. I think colours need at least three variables (red green and blue) to set a color.
    But this is vec4, so it has four numbers in it.
    And also, I’m used to giving these rgb variables a value between 0 and 255.

    But this is not the way this works, it uses smaller numbers (somewhere around 1, usually not less than 0 and not more than 2, correct me if I’m wrong). I found you can use bigger numbers like 1.7 or more, I should try use 8 to see what happens. And also I used negative numbers (0-colorW).

    So yep, I made a few different fluids, but I made them randomly, not knowing what value to give to get a certain result.

    So how do I know what value to give to get a certain colour, and what exactly is colorW?

    Thank you in advance!

    Edit: Oh, and also I’ve read you can modify the fluid’s viscosity. What should I change to do that?

    Oliver Kreylos

    Colors in GLSL have four components: red, green, blue, and alpha (opacity). All component values are normalized from 0.0 to 1.0. Alpha is usually 1.0. I.e., black is (0.0, 0.0, 0.0, 1.0) and white is (1.0, 1.0, 1.0, 1.0).

    vec4 waterColor=vec4(colorW,colorW,1.0,1.0); creates a color between blue when colorW is 0.0 and white when colorW is larger than 1.0.


    Great! Thanks a lot!


    Here is a great post on how to cycle through several different shaders, including many other features: post-108359

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed.