Add lateral chromatic aberration (purple/green fringe) to the cinema postprocessing effects (Rembrandt)
This commit is contained in:
parent
5ebabff309
commit
8e6ed31b94
4 changed files with 116 additions and 19 deletions
|
@ -24,6 +24,8 @@
|
|||
<blue-shift><use>/sim/rendering/rembrandt/cinema/blue-shift</use></blue-shift>
|
||||
<distortion><use>/sim/rendering/rembrandt/cinema/distortion</use></distortion>
|
||||
<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>
|
||||
|
||||
<buffer-nw-enabled><use>/sim/rendering/rembrandt/debug-buffer[0]/enabled</use></buffer-nw-enabled>
|
||||
|
@ -142,6 +144,17 @@
|
|||
<type>float-vec3</type>
|
||||
<value><use>cinema/distortion-factor</use></value>
|
||||
</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>
|
||||
</technique>
|
||||
<technique n="10">
|
||||
|
|
|
@ -13,6 +13,9 @@ uniform float outerCircle;
|
|||
uniform bool distortion;
|
||||
uniform vec3 distortionFactor;
|
||||
|
||||
uniform bool colorFringe;
|
||||
uniform float colorFringeFactor;
|
||||
|
||||
uniform vec2 fg_BufferSize;
|
||||
// uniform float osg_SimulationTime;
|
||||
// uniform float shutterFreq;
|
||||
|
@ -23,31 +26,50 @@ uniform float bloomStrength;
|
|||
uniform bool bloomBuffers;
|
||||
|
||||
void main() {
|
||||
vec2 coords = gl_TexCoord[0].xy;
|
||||
vec2 initialCoords = coords;
|
||||
vec2 c1 = gl_TexCoord[0].xy;
|
||||
vec2 initialCoords = c1;
|
||||
vec2 c2;
|
||||
|
||||
if (distortion) {
|
||||
vec2 c = 2.0 * coords - vec2(1.,1.);
|
||||
c *= vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x );
|
||||
float r = length(c);
|
||||
c1 = 2.0 * initialCoords - vec2(1.,1.);
|
||||
c1 *= vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x );
|
||||
float r = length(c1);
|
||||
|
||||
c += c * dot(distortionFactor.xy, vec2(r*r, r*r*r*r));
|
||||
c /= distortionFactor.z;
|
||||
c1 += c1 * dot(distortionFactor.xy, vec2(r*r, r*r*r*r));
|
||||
c1 /= distortionFactor.z;
|
||||
|
||||
c *= vec2( 1.0, fg_BufferSize.x / fg_BufferSize.y );
|
||||
coords = c * .5 + .5;
|
||||
c1 *= vec2( 1.0, fg_BufferSize.x / fg_BufferSize.y );
|
||||
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)
|
||||
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) {
|
||||
vec3 c2;
|
||||
c2.r = dot(color, redShift);
|
||||
c2.g = dot(color, greenShift);
|
||||
c2.b = dot(color, blueShift);
|
||||
color.rgb = c2;
|
||||
vec3 col2;
|
||||
col2.r = dot(color.rgb, redShift);
|
||||
col2.g = dot(color.rgb, greenShift);
|
||||
col2.b = dot(color.rgb, blueShift);
|
||||
color.rgb = col2;
|
||||
}
|
||||
|
||||
if (vignette) {
|
||||
|
|
|
@ -791,7 +791,7 @@
|
|||
<name>distortion-factor-z</name>
|
||||
<min>0.5</min>
|
||||
<max>1.5</max>
|
||||
<step>0.01</step>
|
||||
<step>0.001</step>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion-factor/z</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
|
@ -812,6 +812,66 @@
|
|||
</text>
|
||||
</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/>
|
||||
|
||||
<group>
|
||||
|
|
|
@ -99,6 +99,8 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<y type="float" userarchive="y">0.0</y>
|
||||
<z type="float" userarchive="y">1.0</z>
|
||||
</distortion-factor>
|
||||
<color-fringe type="bool">false</color-fringe>
|
||||
<color-fringe-factor type="float" userarchive="y">1.0</color-fringe-factor>
|
||||
</cinema>
|
||||
<exposure type="float" userarchive="y">1.0</exposure>
|
||||
<use-color-for-depth type="bool">false</use-color-for-depth>
|
||||
|
|
Loading…
Reference in a new issue