medfall

A super great game engine
Log | Files | Refs

commit cec33e14fea3145636d7c4e834d91acbb0b00786
parent a7a6d64a3f4a4a6a486d3412d9c92286631ee554
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon Aug 28 20:00:03 +0100

Reinhard tonemapping in shadow map example

Diffstat:
shaders/common.glsl | 4++++
shaders/shadowed_vertex_colours.glsl | 2+-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/shaders/common.glsl b/shaders/common.glsl @@ -21,3 +21,7 @@ float unlerp_sat( float x, float lo, float hi ) { float dot_sat( vec3 a, vec3 b ) { return saturate( dot( a, b ) ); } + +vec3 reinhard_tonemap( vec3 c ) { + return c / ( c + vec3( 1.0 ) ); +} diff --git a/shaders/shadowed_vertex_colours.glsl b/shaders/shadowed_vertex_colours.glsl @@ -91,7 +91,7 @@ void main() { vec3 ambient = vec3( 0.03 ) * v2f.colour; vec3 Lo = cook_torrance_brdf( to_camera, v2f.position, v2f.normal, light_pos, light_colour, v2f.colour, 0.75, 0.0 ); - screen_colour = vec4( ambient + Lo * shadow + noise, 1.0 ); + screen_colour = vec4( reinhard_tonemap( ambient + Lo * shadow + noise ), 1.0 ); } #endif