Files
ghostland-game/trailfragshader.glsl

18 lines
472 B
GLSL

#version 330 core
// Colors the trail geometry by age: newest samples are red and old samples
// fade toward brown before they expire from the CPU-side trail window.
out vec4 FragColor;
in float TrailTimestamp;
uniform float currentTime;
uniform float maxAge;
uniform vec3 recentColor;
uniform vec3 oldColor;
void main()
{
float ageRatio = clamp((currentTime - TrailTimestamp) / maxAge, 0.0, 1.0);
FragColor = vec4(mix(recentColor, oldColor, ageRatio), 1.0);
}