1
0
Fork 0

Add lateral chromatic aberration (purple/green fringe) to the cinema postprocessing effects (Rembrandt)

This commit is contained in:
Frederic Bouvier 2012-08-05 11:43:56 +02:00 committed by Vivian Meazza
parent 5ebabff309
commit 8e6ed31b94
4 changed files with 116 additions and 19 deletions

View file

@ -24,6 +24,8 @@
<blue-shift><use>/sim/rendering/rembrandt/cinema/blue-shift</use></blue-shift> <blue-shift><use>/sim/rendering/rembrandt/cinema/blue-shift</use></blue-shift>
<distortion><use>/sim/rendering/rembrandt/cinema/distortion</use></distortion> <distortion><use>/sim/rendering/rembrandt/cinema/distortion</use></distortion>
<distortion-factor><use>/sim/rendering/rembrandt/cinema/distortion-factor</use></distortion-factor> <distortion-factor><use>/sim/rendering/rembrandt/cinema/distortion-factor</use></distortion-factor>
<color-fringe><use>/sim/rendering/rembrandt/cinema/color-fringe</use></color-fringe>
<color-fringe-factor><use>/sim/rendering/rembrandt/cinema/color-fringe-factor</use></color-fringe-factor>
</cinema> </cinema>
<buffer-nw-enabled><use>/sim/rendering/rembrandt/debug-buffer[0]/enabled</use></buffer-nw-enabled> <buffer-nw-enabled><use>/sim/rendering/rembrandt/debug-buffer[0]/enabled</use></buffer-nw-enabled>
@ -142,6 +144,17 @@
<type>float-vec3</type> <type>float-vec3</type>
<value><use>cinema/distortion-factor</use></value> <value><use>cinema/distortion-factor</use></value>
</uniform> </uniform>
<uniform>
<name>colorFringe</name>
<type>bool</type>
<value><use>cinema/color-fringe</use></value>
</uniform>
<uniform>
<name>colorFringeFactor</name>
<type>float</type>
<value><use>cinema/color-fringe-factor</use></value>
</uniform>
</pass> </pass>
</technique> </technique>
<technique n="10"> <technique n="10">

View file

@ -13,6 +13,9 @@ uniform float outerCircle;
uniform bool distortion; uniform bool distortion;
uniform vec3 distortionFactor; uniform vec3 distortionFactor;
uniform bool colorFringe;
uniform float colorFringeFactor;
uniform vec2 fg_BufferSize; uniform vec2 fg_BufferSize;
// uniform float osg_SimulationTime; // uniform float osg_SimulationTime;
// uniform float shutterFreq; // uniform float shutterFreq;
@ -23,31 +26,50 @@ uniform float bloomStrength;
uniform bool bloomBuffers; uniform bool bloomBuffers;
void main() { void main() {
vec2 coords = gl_TexCoord[0].xy; vec2 c1 = gl_TexCoord[0].xy;
vec2 initialCoords = coords; vec2 initialCoords = c1;
vec2 c2;
if (distortion) { if (distortion) {
vec2 c = 2.0 * coords - vec2(1.,1.); c1 = 2.0 * initialCoords - vec2(1.,1.);
c *= vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x ); c1 *= vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x );
float r = length(c); float r = length(c1);
c += c * dot(distortionFactor.xy, vec2(r*r, r*r*r*r)); c1 += c1 * dot(distortionFactor.xy, vec2(r*r, r*r*r*r));
c /= distortionFactor.z; c1 /= distortionFactor.z;
c *= vec2( 1.0, fg_BufferSize.x / fg_BufferSize.y ); c1 *= vec2( 1.0, fg_BufferSize.x / fg_BufferSize.y );
coords = c * .5 + .5; c1 = c1 * .5 + .5;
if (colorFringe) {
c2 = 2.0 * initialCoords - vec2(1.,1.);
c2 *= vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x );
r = length(c2);
c2 += c2 * dot(distortionFactor.xy*colorFringeFactor, vec2(r*r, r*r*r*r));
c2 /= distortionFactor.z;
c2 *= vec2( 1.0, fg_BufferSize.x / fg_BufferSize.y );
c2 = c2 * .5 + .5;
}
} }
vec4 color = texture2D( lighting_tex, coords ); vec4 color = texture2D( lighting_tex, c1 );
if (bloomEnabled && bloomBuffers) if (bloomEnabled && bloomBuffers)
color = color + bloomStrength * texture2D( bloom_tex, coords ); color += bloomStrength * texture2D( bloom_tex, c1 );
if (distortion && colorFringe) {
color.g = texture2D( lighting_tex, c2 ).g;
if (bloomEnabled && bloomBuffers)
color.g += bloomStrength * texture2D( bloom_tex, c2 ).g;
}
if (colorShift) { if (colorShift) {
vec3 c2; vec3 col2;
c2.r = dot(color, redShift); col2.r = dot(color.rgb, redShift);
c2.g = dot(color, greenShift); col2.g = dot(color.rgb, greenShift);
c2.b = dot(color, blueShift); col2.b = dot(color.rgb, blueShift);
color.rgb = c2; color.rgb = col2;
} }
if (vignette) { if (vignette) {

View file

@ -195,7 +195,7 @@
</combo> </combo>
</group> </group>
<group> <group>
<layout>hbox</layout> <layout>hbox</layout>
<halign>right</halign> <halign>right</halign>
@ -234,7 +234,7 @@
<pref-width>222</pref-width> <pref-width>222</pref-width>
</empty> </empty>
</group> </group>
<group> <group>
<layout>hbox</layout> <layout>hbox</layout>
<halign>right</halign> <halign>right</halign>
@ -791,7 +791,7 @@
<name>distortion-factor-z</name> <name>distortion-factor-z</name>
<min>0.5</min> <min>0.5</min>
<max>1.5</max> <max>1.5</max>
<step>0.01</step> <step>0.001</step>
<property>/sim/rendering/rembrandt/cinema/distortion-factor/z</property> <property>/sim/rendering/rembrandt/cinema/distortion-factor/z</property>
<binding> <binding>
<command>dialog-apply</command> <command>dialog-apply</command>
@ -812,6 +812,66 @@
</text> </text>
</group> </group>
<group>
<layout>hbox</layout>
<halign>left</halign>
<checkbox>
<halign>left</halign>
<label>Color fringe</label>
<name>color-fringe</name>
<property>/sim/rendering/rembrandt/cinema/color-fringe</property>
<binding>
<command>dialog-apply</command>
<object-name>color-fringe</object-name>
</binding>
<enable>
<property>/sim/rendering/rembrandt/cinema/distortion</property>
</enable>
</checkbox>
<empty>
<pref-width>42</pref-width>
</empty>
<text>
<label>Factor</label>
<enable>
<and>
<property>/sim/rendering/rembrandt/cinema/distortion</property>
<property>/sim/rendering/rembrandt/cinema/color-fringe</property>
</and>
</enable>
</text>
<slider>
<name>color-fringe-factor</name>
<min>0.96</min>
<max>1.04</max>
<step>0.001</step>
<property>/sim/rendering/rembrandt/cinema/color-fringe-factor</property>
<binding>
<command>dialog-apply</command>
<object-name>color-fringe-factor</object-name>
</binding>
<enable>
<and>
<property>/sim/rendering/rembrandt/cinema/distortion</property>
<property>/sim/rendering/rembrandt/cinema/color-fringe</property>
</and>
</enable>
</slider>
<text>
<label>12345678</label>
<format>%.3f</format>
<live>true</live>
<property>/sim/rendering/rembrandt/cinema/color-fringe-factor</property>
<enable>
<and>
<property>/sim/rendering/rembrandt/cinema/distortion</property>
<property>/sim/rendering/rembrandt/cinema/color-fringe</property>
</and>
</enable>
</text>
</group>
<hrule/> <hrule/>
<group> <group>

View file

@ -99,6 +99,8 @@ Started September 2000 by David Megginson, david@megginson.com
<y type="float" userarchive="y">0.0</y> <y type="float" userarchive="y">0.0</y>
<z type="float" userarchive="y">1.0</z> <z type="float" userarchive="y">1.0</z>
</distortion-factor> </distortion-factor>
<color-fringe type="bool">false</color-fringe>
<color-fringe-factor type="float" userarchive="y">1.0</color-fringe-factor>
</cinema> </cinema>
<exposure type="float" userarchive="y">1.0</exposure> <exposure type="float" userarchive="y">1.0</exposure>
<use-color-for-depth type="bool">false</use-color-for-depth> <use-color-for-depth type="bool">false</use-color-for-depth>