Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Trap Water Altitude/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Trap Water Altitude
> by SpacEagle17

This shader snippet provides a custom uniform to record the altitude of water bodies. The recorded altitude:

- Defaults to 61.9 when exiting water, entering from a cave, or during shader reload
- Maintains the entered altitude value until the player exits the water
- Uses a smooth transition technique to capture the eye altitude while in water

The code should be added to your `shaders.properties` file. Then, to use this functionality, declare the uniform in your shader program like this:
```glsl
uniform float waterAltitude = 61.9; // Tracks the altitude of water bodies, with default value for fallback
```
Works on Iris and OptiFine
Special thanks to Xonk for the large number smooth() trick used to record values.

> Used in Euphoria Patches to progressively darken water as the player descends deeper

For more information about custom uniforms, visit the [shaders.properties documentation](https://shaders.properties/current/reference/shadersproperties/custom_uniforms/).
6 changes: 6 additions & 0 deletions Trap Water Altitude/trap-water-altitude.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# By SpacEagle17
# Add the following code to your shaders.properties file.

variable.float.trapWater = if(isEyeInWater == 1, 100000000000000.0, 0.0)
variable.float.trapEyeAltitude = smooth(if(eyeBrightness.y < 224.0, 61.9, eyeAltitude - 1), trapWater, trapWater)
uniform.float.waterAltitude = if(isEyeInWater != 1, 61.9, trapEyeAltitude)