Water to Lava

Home Forums AR Sandbox Forum Water to Lava

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

    I understand a few lines of code can be changed to make the water appear as lava. Is there documentation for this? Is there any way that we could simply switch back and forth between modes?

    Oliver Kreylos

    The water effect is achieved by a GLSL fragment shader, whose source code is in SurfaceAddWaterColor.fs in the SARndbox package’s shader directory, share/SARndbox-<version>/Shaders.

    To switch the water to appear as lava (this only affects appearance, not behavior), change the following lines in the source file:

    Uncomment line 170:

    float colorW=max(turb(vec3(fragCoord*0.05,waterAnimationTime*0.25)),0.0); // Turbulence noise

    Comment out line 177:

    // float colorW=pow(dot(wn,normalize(vec3(0.075,0.075,1.0))),100.0)*1.0-0.0;

    Comment/uncomment lines 179 and 180:

    // vec4 waterColor=vec4(colorW,colorW,1.0,1.0); // Water
    vec4 waterColor=vec4(1.0-colorW,1.0-colorW*2.0,0.0,1.0); // Lava

    Then save the source file. If the AR Sandbox is already running, the change will take effect immediately; otherwise, it will take effect when the SARndbox executable is started the next time.

    To go back to water-colored water, reverse the steps above.

    Another option is to create two copies of the shader file, say SurfaceAddWaterColor-Water.fs and SurfaceAddWaterColor-Lava.fs, make the above changes in the second file, and then use a script on an icon or hotkey to copy either file onto the one that’s used by the Sandbox, such as

    $ cp SurfaceAddWaterColor-Lava.fs SurfaceAddWaterColor.fs

    to set “lava mode,” and

    $ cp SurfaceAddWaterColor-Water.fs SurfaceAddWaterColor.fs

    to set “water mode.”


    So after trying again and again to get this to switch to lava I have run into an issue. When the sandbox application is running it will not update to lava when I do the following steps as suggested above. I get no sort of live update to the program after I save the edited SurfaceAddWaterColor.fs file. The only way that I get it to work is if I quit the sandbox application and restart it. Any idea as to why this is?

    I’m currently running the sandbox in Linux Mint MATE 17.2 fyi.

    • This reply was modified 5 years, 8 months ago by LoganB.

    i have about 6 different shaders I switch on the fly, from water to toxic waste.
    INTPTT and Jensen have been very helpful in this matter

    if you have Linux mint, you can use keyboard shortcuts.
    create 2 scripts, one that has the new values of the shader (lava,snow,ice),
    for this example mine is called SurfaceAddWaterColor-Lava.fs = shader file to make lava

    and one that renames it to the default water shader file. cp SurfaceAddWaterColor-Lava.fs SurfaceAddWaterColor.fs
    then by executing this file you take the lava shader and rename it to the default water shader file name.
    the change script will say cp SurfaceAddWaterColor-Lava.fs SurfaceAddWaterColor.fs
    you can test it by opening a console while your box is running, and you can see the shaders change.

    the sandbox always uses the water shader, so if you have a shader that makes lava but save it as the water shader name, then when you make it rain, it will be lava and not water.

    then repeat that for every type of shader you are making.

    I hope I did not confuse you more, there are other links I had with the guys but I can’t find where. they helped me out when creating my shaders.
    I did find this one helpful link where I started the process

    • This reply was modified 5 years, 8 months ago by billberet.
    • This reply was modified 5 years, 8 months ago by billberet.
    • This reply was modified 5 years, 8 months ago by billberet.
    • This reply was modified 5 years, 8 months ago by billberet.
    • This reply was modified 5 years, 8 months ago by billberet.
    • This reply was modified 5 years, 8 months ago by billberet.
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed.