How to modify water shaders

Home Forums AR Sandbox Forum How to modify water shaders

Tagged: 

This topic contains 3 replies, has 3 voices, and was last updated by  clifcox 4 months, 4 weeks ago.

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

    Noriel_Sylvire
    Participant

    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?

    #113676

    Oliver Kreylos
    Keymaster

    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.

    #114690

    Noriel_Sylvire
    Participant

    Great! Thanks a lot!

    #115437

    clifcox
    Participant

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

    • This reply was modified 4 months, 4 weeks ago by  clifcox.
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Comments are closed.