Reply To: Water to Lava

Home Forums AR Sandbox Forum Water to Lava Reply To: Water to Lava

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

Comments are closed.