From fd5fa77469c7b5e2b08d2daf265d31b1bc9e8053 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Sun, 5 Aug 2012 00:04:41 +0200 Subject: [PATCH] Cinema effects in the Rembrandt framework --- Effects/display.eff | 107 ++++++++++++++ Shaders/cinema.frag | 47 ++++++ gui/dialogs/rembrandt.xml | 292 ++++++++++++++++++++++++++++++++++++-- preferences.xml | 21 +++ 4 files changed, 457 insertions(+), 10 deletions(-) create mode 100644 Shaders/cinema.frag diff --git a/Effects/display.eff b/Effects/display.eff index 1fbf93ddf..a5624dcf4 100644 --- a/Effects/display.eff +++ b/Effects/display.eff @@ -14,6 +14,16 @@ normalized + + /sim/rendering/rembrandt/cinema/vignette + /sim/rendering/rembrandt/cinema/inner-circle + /sim/rendering/rembrandt/cinema/outer-circle + /sim/rendering/rembrandt/cinema/color-shift + /sim/rendering/rembrandt/cinema/red-shift + /sim/rendering/rembrandt/cinema/green-shift + /sim/rendering/rembrandt/cinema/blue-shift + + /sim/rendering/rembrandt/debug-buffer[0]/enabled /sim/rendering/rembrandt/debug-buffer[0]/name /sim/rendering/rembrandt/debug-buffer[1]/enabled @@ -23,6 +33,103 @@ /sim/rendering/rembrandt/debug-buffer[3]/enabled /sim/rendering/rembrandt/debug-buffer[3]/name + + + + + /sim/rendering/rembrandt/cinema/vignette + /sim/rendering/rembrandt/cinema/color-shift + + + 0.0 + /sim/rendering/rembrandt/show-buffers + + + + + + 99999 + RenderBin + + + 0 + buffer + lighting + + + 1 + buffer + bloom-3 + + + + Shaders/fullscreen.vert + Shaders/cinema.frag + + + lighting_tex + sampler-2d + 0 + + + bloom_tex + sampler-2d + 1 + + + + bloomEnabled + bool + bloom + + + bloomStrength + float + bloom-strength + + + bloomBuffers + bool + bloom-buffers + + + + vignette + bool + cinema/vignette + + + innerCircle + float + cinema/inner-circle + + + outerCircle + float + cinema/outer-circle + + + colorShift + bool + cinema/color-shift + + + redShift + float-vec3 + cinema/red-shift + + + greenShift + float-vec3 + cinema/green-shift + + + blueShift + float-vec3 + cinema/blue-shift + + + diff --git a/Shaders/cinema.frag b/Shaders/cinema.frag new file mode 100644 index 000000000..1352e4215 --- /dev/null +++ b/Shaders/cinema.frag @@ -0,0 +1,47 @@ +uniform sampler2D lighting_tex; +uniform sampler2D bloom_tex; + +uniform bool colorShift; +uniform vec3 redShift; +uniform vec3 greenShift; +uniform vec3 blueShift; + +uniform bool vignette; +uniform float innerCircle; +uniform float outerCircle; + +uniform vec2 fg_BufferSize; +// uniform float osg_SimulationTime; +// uniform float shutterFreq; +// uniform float shutterDuration; + +uniform bool bloomEnabled; +uniform float bloomStrength; +uniform bool bloomBuffers; + +void main() { + vec2 coords = gl_TexCoord[0].xy; + vec4 color = texture2D( lighting_tex, coords ); + if (bloomEnabled && bloomBuffers) + color = color + bloomStrength * texture2D( bloom_tex, coords ); + + if (colorShift) { + vec3 c2; + c2.r = dot(color, redShift); + c2.g = dot(color, greenShift); + c2.b = dot(color, blueShift); + color.rgb = c2; + } + + if (vignette) { + vec2 c = 2.0 * coords - vec2(1.,1.); + c = c * vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x ); + float l = length(c); + float f = smoothstep( innerCircle, innerCircle * outerCircle, l ); + color.rgb = (1 - f) * color.rgb; + } + // if ((osg_FrameNumber % 6) == 0) + // f = 1.0; + + gl_FragColor = color; +} diff --git a/gui/dialogs/rembrandt.xml b/gui/dialogs/rembrandt.xml index 65b1716bd..35733bff6 100644 --- a/gui/dialogs/rembrandt.xml +++ b/gui/dialogs/rembrandt.xml @@ -52,7 +52,7 @@ - 66 + 63 @@ -111,7 +111,7 @@ - -4 + -7 @@ -170,7 +170,7 @@ - 45 + 42 @@ -231,7 +231,7 @@ /sim/rendering/shadows/filtering - 67 + 114 @@ -289,18 +289,14 @@ /sim/rendering/shadows/num-cascades - 67 + 114 hbox right - - - 130 - - + @@ -373,6 +369,274 @@ shadow-cascade-4 + + 39 + + + + + + + hbox + left + + + left + + vignette + /sim/rendering/rembrandt/cinema/vignette + + dialog-apply + vignette + + + + 34 + + + + + /sim/rendering/rembrandt/cinema/vignette + + + + inner-circle + 0.0 + 1.5 + 0.01 + /sim/rendering/rembrandt/cinema/inner-circle + + dialog-apply + inner-circle + + + /sim/rendering/rembrandt/cinema/vignette + + + + + %.2f + true + /sim/rendering/rembrandt/cinema/inner-circle + + /sim/rendering/rembrandt/cinema/vignette + + + + + + hbox + right + + + + + /sim/rendering/rembrandt/cinema/vignette + + + + outer-circle + 1.0 + 2.0 + 0.01 + /sim/rendering/rembrandt/cinema/outer-circle + + dialog-apply + outer-circle + + + /sim/rendering/rembrandt/cinema/vignette + + + + + %.2f + true + /sim/rendering/rembrandt/cinema/outer-circle + + /sim/rendering/rembrandt/cinema/vignette + + + + 114 + + + + + + + hbox + left + + + left + + color-shift + /sim/rendering/rembrandt/cinema/color-shift + + dialog-apply + color-shift + + + + 37 + + + + + /sim/rendering/rembrandt/cinema/color-shift + + + + red-shift-r + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/red-shift/x + + dialog-apply + red-shift-r + + + /sim/rendering/rembrandt/cinema/color-shift + + + + red-shift-g + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/red-shift/y + + dialog-apply + red-shift-g + + + /sim/rendering/rembrandt/cinema/color-shift + + + + red-shift-b + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/red-shift/z + + dialog-apply + red-shift-b + + + /sim/rendering/rembrandt/cinema/color-shift + + + + + + hbox + right + + + + + /sim/rendering/rembrandt/cinema/color-shift + + + + green-shift-r + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/green-shift/x + + dialog-apply + green-shift-r + + + /sim/rendering/rembrandt/cinema/color-shift + + + + green-shift-g + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/green-shift/y + + dialog-apply + green-shift-g + + + /sim/rendering/rembrandt/cinema/color-shift + + + + green-shift-b + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/green-shift/z + + dialog-apply + green-shift-b + + + /sim/rendering/rembrandt/cinema/color-shift + + + + + + hbox + right + + + + + /sim/rendering/rembrandt/cinema/color-shift + + + + blue-shift-r + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/blue-shift/x + + dialog-apply + blue-shift-r + + + /sim/rendering/rembrandt/cinema/color-shift + + + + blue-shift-g + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/blue-shift/y + + dialog-apply + blue-shift-g + + + /sim/rendering/rembrandt/cinema/color-shift + + + + blue-shift-b + 0.0 + 1.0 + 0.01 + /sim/rendering/rembrandt/cinema/blue-shift/z + + dialog-apply + blue-shift-b + + + /sim/rendering/rembrandt/cinema/color-shift + + @@ -390,6 +654,14 @@ dialog-apply night-vision + + + + /sim/rendering/rembrandt/cinema/color-shift + /sim/rendering/rembrandt/cinema/vignette + + + diff --git a/preferences.xml b/preferences.xml index b115350ad..02435746e 100644 --- a/preferences.xml +++ b/preferences.xml @@ -73,6 +73,27 @@ Started September 2000 by David Megginson, david@megginson.com 1.0 true false + + false + 0.8 + 1.3 + false + + .393 + .769 + .189 + + + .349 + .686 + .168 + + + .272 + .534 + .131 + + 1.0 false true