39 lines
1.1 KiB
GLSL
39 lines
1.1 KiB
GLSL
uniform float m_Interval;
|
|
uniform float m_LineWidth;
|
|
uniform float m_Opacity;
|
|
|
|
in float vWorldY;
|
|
|
|
out vec4 outColor;
|
|
|
|
// Maps height to a blue→green→yellow→red gradient
|
|
vec3 heightColor(float t) {
|
|
t = clamp(t, 0.0, 1.0);
|
|
vec3 c;
|
|
if (t < 0.25) {
|
|
c = mix(vec3(0.0, 0.0, 0.8), vec3(0.0, 0.7, 0.7), t * 4.0);
|
|
} else if (t < 0.5) {
|
|
c = mix(vec3(0.0, 0.7, 0.7), vec3(0.2, 0.8, 0.1), (t - 0.25) * 4.0);
|
|
} else if (t < 0.75) {
|
|
c = mix(vec3(0.2, 0.8, 0.1), vec3(0.9, 0.8, 0.0), (t - 0.5) * 4.0);
|
|
} else {
|
|
c = mix(vec3(0.9, 0.8, 0.0), vec3(0.8, 0.1, 0.0), (t - 0.75) * 4.0);
|
|
}
|
|
return c;
|
|
}
|
|
|
|
void main() {
|
|
float minH = -20.0;
|
|
float maxH = 300.0;
|
|
float t = (vWorldY - minH) / (maxH - minH);
|
|
vec3 band = heightColor(t);
|
|
|
|
// Contour lines: sharp pulse near each interval boundary
|
|
float phase = fract(vWorldY / m_Interval);
|
|
float fw = fwidth(vWorldY / m_Interval);
|
|
float line = 1.0 - smoothstep(m_LineWidth - fw, m_LineWidth + fw, min(phase, 1.0 - phase));
|
|
|
|
vec3 color = mix(band, vec3(0.0), line * 0.75);
|
|
outColor = vec4(color, m_Opacity);
|
|
}
|