commit cc4f59342fa0f4597b4bb59333509c0e9012d0f3 parent 2c0eaa47b85d36c031fbffb7804868ebb99efdf3 Author: Michael Savage <mikejsavage@gmail.com> Date: Wed Jul 12 20:41:52 +0300 Better naming Diffstat:
shaders/skybox.glsl | | | 12 | ++++++++---- |
diff --git a/shaders/skybox.glsl b/shaders/skybox.glsl @@ -23,8 +23,12 @@ layout( std140 ) uniform sun { float sun_angle; }; -float asdf( float x, float lo, float hi ) { - return clamp( ( x - lo ) / ( hi - lo ), 0.0, 1.0 ); +float saturate( float x ) { + return clamp( x, 0.0, 1.0 ); +} + +float unlerp_sat( float x, float lo, float hi ) { + return saturate( ( x - lo ) / ( hi - lo ) ); } float hdot( vec3 u, vec3 v ) { @@ -59,8 +63,8 @@ void main() { float dawn_sun_angle = 0.0; float day_sun_angle = 1.0; - float night_to_dawn = asdf( sun_angle, night_sun_angle, dawn_sun_angle ); - float dawn_to_day = asdf( sun_angle, dawn_sun_angle, day_sun_angle ); + float night_to_dawn = unlerp_sat( sun_angle, night_sun_angle, dawn_sun_angle ); + float dawn_to_day = unlerp_sat( sun_angle, dawn_sun_angle, day_sun_angle ); day_colour += vec3( 0.5, 0.2, 0.0 ) * halo_intensity * 0.5 * dawn_to_day; vec3 night_colour = mix( night, sunny, sun_intensity );