ile-de-test/addons/waterways/shaders/system_renders/system_height.gdshader
2024-01-26 21:00:32 +01:00

27 lines
No EOL
709 B
Text

shader_type spatial;
render_mode unshaded;
uniform float lower_bounds = 0.0;
uniform float upper_bounds = 10.0;
varying vec3 vertex_trans;
// Converts a color from sRGB gamma to linear light gamma
vec4 toLinear(vec4 sRGB)
{
bvec4 cutoff = lessThan(sRGB, vec4(0.04045));
vec4 higher = pow((sRGB + vec4(0.055))/vec4(1.055), vec4(2.4));
vec4 lower = sRGB/vec4(12.92);
return mix(higher, lower, cutoff);
}
void vertex() {
vertex_trans = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
}
void fragment() {
float range = upper_bounds - lower_bounds;
float height = clamp((vertex_trans.y - lower_bounds) / range, 0.0, 1.0);
//height = toLinear(vec4(vec3(height), 1.0)).r;
ALBEDO = vec3( height );
}