1
0
Fork 0

Cinema effects in the Rembrandt framework

This commit is contained in:
Frederic Bouvier 2012-08-05 00:04:41 +02:00
parent 191bddc5b1
commit fd5fa77469
4 changed files with 457 additions and 10 deletions

View file

@ -14,6 +14,16 @@
<internal-format>normalized</internal-format>
</texture>
<cinema>
<vignette><use>/sim/rendering/rembrandt/cinema/vignette</use></vignette>
<inner-circle><use>/sim/rendering/rembrandt/cinema/inner-circle</use></inner-circle>
<outer-circle><use>/sim/rendering/rembrandt/cinema/outer-circle</use></outer-circle>
<color-shift><use>/sim/rendering/rembrandt/cinema/color-shift</use></color-shift>
<red-shift><use>/sim/rendering/rembrandt/cinema/red-shift</use></red-shift>
<green-shift><use>/sim/rendering/rembrandt/cinema/green-shift</use></green-shift>
<blue-shift><use>/sim/rendering/rembrandt/cinema/blue-shift</use></blue-shift>
</cinema>
<buffer-nw-enabled><use>/sim/rendering/rembrandt/debug-buffer[0]/enabled</use></buffer-nw-enabled>
<buffer-nw-name><use>/sim/rendering/rembrandt/debug-buffer[0]/name</use></buffer-nw-name>
<buffer-ne-enabled><use>/sim/rendering/rembrandt/debug-buffer[1]/enabled</use></buffer-ne-enabled>
@ -23,6 +33,103 @@
<buffer-se-enabled><use>/sim/rendering/rembrandt/debug-buffer[3]/enabled</use></buffer-se-enabled>
<buffer-se-name><use>/sim/rendering/rembrandt/debug-buffer[3]/name</use></buffer-se-name>
</parameters>
<technique n="9">
<predicate>
<and>
<or>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</or>
<equal>
<value type="float">0.0</value>
<float-property>/sim/rendering/rembrandt/show-buffers</float-property>
</equal>
</and>
</predicate>
<pass>
<render-bin>
<bin-number>99999</bin-number>
<bin-name>RenderBin</bin-name>
</render-bin>
<texture-unit>
<unit>0</unit>
<type>buffer</type>
<name>lighting</name>
</texture-unit>
<texture-unit>
<unit>1</unit>
<type>buffer</type>
<name>bloom-3</name>
</texture-unit>
<program>
<vertex-shader>Shaders/fullscreen.vert</vertex-shader>
<fragment-shader>Shaders/cinema.frag</fragment-shader>
</program>
<uniform>
<name>lighting_tex</name>
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>bloom_tex</name>
<type>sampler-2d</type>
<value type="int">1</value>
</uniform>
<uniform>
<name>bloomEnabled</name>
<type>bool</type>
<value type="bool"><use>bloom</use></value>
</uniform>
<uniform>
<name>bloomStrength</name>
<type>float</type>
<value><use>bloom-strength</use></value>
</uniform>
<uniform>
<name>bloomBuffers</name>
<type>bool</type>
<value><use>bloom-buffers</use></value>
</uniform>
<uniform>
<name>vignette</name>
<type>bool</type>
<value><use>cinema/vignette</use></value>
</uniform>
<uniform>
<name>innerCircle</name>
<type>float</type>
<value><use>cinema/inner-circle</use></value>
</uniform>
<uniform>
<name>outerCircle</name>
<type>float</type>
<value><use>cinema/outer-circle</use></value>
</uniform>
<uniform>
<name>colorShift</name>
<type>bool</type>
<value><use>cinema/color-shift</use></value>
</uniform>
<uniform>
<name>redShift</name>
<type>float-vec3</type>
<value><use>cinema/red-shift</use></value>
</uniform>
<uniform>
<name>greenShift</name>
<type>float-vec3</type>
<value><use>cinema/green-shift</use></value>
</uniform>
<uniform>
<name>blueShift</name>
<type>float-vec3</type>
<value><use>cinema/blue-shift</use></value>
</uniform>
</pass>
</technique>
<technique n="10">
<predicate>
<and>

47
Shaders/cinema.frag Normal file
View file

@ -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;
}

View file

@ -52,7 +52,7 @@
</enable>
</checkbox>
<empty>
<pref-width>66</pref-width>
<pref-width>63</pref-width>
</empty>
<text>
<label>Strength</label>
@ -111,7 +111,7 @@
</enable>
</checkbox>
<empty>
<pref-width>-4</pref-width>
<pref-width>-7</pref-width>
</empty>
<text>
<label>Strength</label>
@ -170,7 +170,7 @@
</binding>
</checkbox>
<empty>
<pref-width>45</pref-width>
<pref-width>42</pref-width>
</empty>
<text>
<label>Map size</label>
@ -231,7 +231,7 @@
<property>/sim/rendering/shadows/filtering</property>
</text>
<empty>
<pref-width>67</pref-width>
<pref-width>114</pref-width>
</empty>
</group>
@ -289,7 +289,7 @@
<property>/sim/rendering/shadows/num-cascades</property>
</text>
<empty>
<pref-width>67</pref-width>
<pref-width>114</pref-width>
</empty>
</group>
@ -297,10 +297,6 @@
<layout>hbox</layout>
<halign>right</halign>
<empty>
<pref-width>130</pref-width>
</empty>
<text>
<label>Cascades</label>
<enable>
@ -373,6 +369,274 @@
<object-name>shadow-cascade-4</object-name>
</binding>
</input>
<empty>
<pref-width>39</pref-width>
</empty>
</group>
<hrule/>
<group>
<layout>hbox</layout>
<halign>left</halign>
<checkbox>
<halign>left</halign>
<label>Vignette</label>
<name>vignette</name>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
<binding>
<command>dialog-apply</command>
<object-name>vignette</object-name>
</binding>
</checkbox>
<empty>
<pref-width>34</pref-width>
</empty>
<text>
<label>Inner circle</label>
<enable>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
</enable>
</text>
<slider>
<name>inner-circle</name>
<min>0.0</min>
<max>1.5</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/inner-circle</property>
<binding>
<command>dialog-apply</command>
<object-name>inner-circle</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
</enable>
</slider>
<text>
<label>12345678</label>
<format>%.2f</format>
<live>true</live>
<property>/sim/rendering/rembrandt/cinema/inner-circle</property>
<enable>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
</enable>
</text>
</group>
<group>
<layout>hbox</layout>
<halign>right</halign>
<text>
<label>Outer circle</label>
<enable>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
</enable>
</text>
<slider>
<name>outer-circle</name>
<min>1.0</min>
<max>2.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/outer-circle</property>
<binding>
<command>dialog-apply</command>
<object-name>outer-circle</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
</enable>
</slider>
<text>
<label>12345678</label>
<format>%.2f</format>
<live>true</live>
<property>/sim/rendering/rembrandt/cinema/outer-circle</property>
<enable>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
</enable>
</text>
<empty>
<pref-width>114</pref-width>
</empty>
</group>
<hrule/>
<group>
<layout>hbox</layout>
<halign>left</halign>
<checkbox>
<halign>left</halign>
<label>Color shift</label>
<name>color-shift</name>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
<binding>
<command>dialog-apply</command>
<object-name>color-shift</object-name>
</binding>
</checkbox>
<empty>
<pref-width>37</pref-width>
</empty>
<text>
<label>Red shift</label>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</text>
<slider>
<name>red-shift-r</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/red-shift/x</property>
<binding>
<command>dialog-apply</command>
<object-name>red-shift-r</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
<slider>
<name>red-shift-g</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/red-shift/y</property>
<binding>
<command>dialog-apply</command>
<object-name>red-shift-g</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
<slider>
<name>red-shift-b</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/red-shift/z</property>
<binding>
<command>dialog-apply</command>
<object-name>red-shift-b</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
</group>
<group>
<layout>hbox</layout>
<halign>right</halign>
<text>
<label>Green shift</label>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</text>
<slider>
<name>green-shift-r</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/green-shift/x</property>
<binding>
<command>dialog-apply</command>
<object-name>green-shift-r</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
<slider>
<name>green-shift-g</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/green-shift/y</property>
<binding>
<command>dialog-apply</command>
<object-name>green-shift-g</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
<slider>
<name>green-shift-b</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/green-shift/z</property>
<binding>
<command>dialog-apply</command>
<object-name>green-shift-b</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
</group>
<group>
<layout>hbox</layout>
<halign>right</halign>
<text>
<label>Blue shift</label>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</text>
<slider>
<name>blue-shift-r</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/blue-shift/x</property>
<binding>
<command>dialog-apply</command>
<object-name>blue-shift-r</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
<slider>
<name>blue-shift-g</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/blue-shift/y</property>
<binding>
<command>dialog-apply</command>
<object-name>blue-shift-g</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
<slider>
<name>blue-shift-b</name>
<min>0.0</min>
<max>1.0</max>
<step>0.01</step>
<property>/sim/rendering/rembrandt/cinema/blue-shift/z</property>
<binding>
<command>dialog-apply</command>
<object-name>blue-shift-b</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
</enable>
</slider>
</group>
<hrule/>
@ -390,6 +654,14 @@
<command>dialog-apply</command>
<object-name>night-vision</object-name>
</binding>
<enable>
<not>
<or>
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
<property>/sim/rendering/rembrandt/cinema/vignette</property>
</or>
</not>
</enable>
</checkbox>
</group>

View file

@ -73,6 +73,27 @@ Started September 2000 by David Megginson, david@megginson.com
<bloom-strength type="float" userarchive="y">1.0</bloom-strength>
<bloom-buffers type="bool">true</bloom-buffers>
<night-vision type="bool">false</night-vision>
<cinema>
<vignette type="bool">false</vignette>
<inner-circle type="float" userarchive="y">0.8</inner-circle>
<outer-circle type="float" userarchive="y">1.3</outer-circle>
<color-shift type="bool">false</color-shift>
<red-shift>
<x type="float" userarchive="y">.393</x>
<y type="float" userarchive="y">.769</y>
<z type="float" userarchive="y">.189</z>
</red-shift>
<green-shift>
<x type="float" userarchive="y">.349</x>
<y type="float" userarchive="y">.686</y>
<z type="float" userarchive="y">.168</z>
</green-shift>
<blue-shift>
<x type="float" userarchive="y">.272</x>
<y type="float" userarchive="y">.534</y>
<z type="float" userarchive="y">.131</z>
</blue-shift>
</cinema>
<exposure type="float" userarchive="y">1.0</exposure>
<use-color-for-depth type="bool">false</use-color-for-depth>
<no-16bit-buffer type="bool">true</no-16bit-buffer>