Add radial lens distortion to the cinema postprocessing effects (Rembrandt)
This commit is contained in:
parent
aa45627ec3
commit
5907f9469d
4 changed files with 130 additions and 2 deletions
|
@ -22,6 +22,8 @@
|
|||
<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>
|
||||
<distortion><use>/sim/rendering/rembrandt/cinema/distortion</use></distortion>
|
||||
<distortion-factor><use>/sim/rendering/rembrandt/cinema/distortion-factor</use></distortion-factor>
|
||||
</cinema>
|
||||
|
||||
<buffer-nw-enabled><use>/sim/rendering/rembrandt/debug-buffer[0]/enabled</use></buffer-nw-enabled>
|
||||
|
@ -39,6 +41,7 @@
|
|||
<or>
|
||||
<property>/sim/rendering/rembrandt/cinema/vignette</property>
|
||||
<property>/sim/rendering/rembrandt/cinema/color-shift</property>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</or>
|
||||
<equal>
|
||||
<value type="float">0.0</value>
|
||||
|
@ -128,6 +131,17 @@
|
|||
<type>float-vec3</type>
|
||||
<value><use>cinema/blue-shift</use></value>
|
||||
</uniform>
|
||||
|
||||
<uniform>
|
||||
<name>distortion</name>
|
||||
<type>bool</type>
|
||||
<value><use>cinema/distortion</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>distortionFactor</name>
|
||||
<type>float-vec3</type>
|
||||
<value><use>cinema/distortion-factor</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
<technique n="10">
|
||||
|
|
|
@ -10,6 +10,9 @@ uniform bool vignette;
|
|||
uniform float innerCircle;
|
||||
uniform float outerCircle;
|
||||
|
||||
uniform bool distortion;
|
||||
uniform vec3 distortionFactor;
|
||||
|
||||
uniform vec2 fg_BufferSize;
|
||||
// uniform float osg_SimulationTime;
|
||||
// uniform float shutterFreq;
|
||||
|
@ -21,6 +24,19 @@ uniform bool bloomBuffers;
|
|||
|
||||
void main() {
|
||||
vec2 coords = gl_TexCoord[0].xy;
|
||||
|
||||
if (distortion) {
|
||||
vec2 c = 2.0 * coords - vec2(1.,1.);
|
||||
c *= vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x );
|
||||
float r = length(c);
|
||||
|
||||
c += c * dot(distortionFactor.xy, vec2(r*r, r*r*r*r));
|
||||
c /= distortionFactor.z;
|
||||
|
||||
c *= vec2( 1.0, fg_BufferSize.x / fg_BufferSize.y );
|
||||
coords = c * .5 + .5;
|
||||
}
|
||||
|
||||
vec4 color = texture2D( lighting_tex, coords );
|
||||
if (bloomEnabled && bloomBuffers)
|
||||
color = color + bloomStrength * texture2D( bloom_tex, coords );
|
||||
|
|
|
@ -462,8 +462,6 @@
|
|||
</empty>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>left</halign>
|
||||
|
@ -720,6 +718,100 @@
|
|||
</text>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>left</halign>
|
||||
|
||||
<checkbox>
|
||||
<halign>left</halign>
|
||||
<label>Distortion</label>
|
||||
<name>distortion</name>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>distortion</object-name>
|
||||
</binding>
|
||||
</checkbox>
|
||||
<empty>
|
||||
<pref-width>48</pref-width>
|
||||
</empty>
|
||||
<text>
|
||||
<label>Factors</label>
|
||||
<enable>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</enable>
|
||||
</text>
|
||||
<slider>
|
||||
<name>distortion-factor-x</name>
|
||||
<min>-0.5</min>
|
||||
<max>0.5</max>
|
||||
<step>0.01</step>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion-factor/x</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>distortion-factor-x</object-name>
|
||||
</binding>
|
||||
<enable>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</enable>
|
||||
</slider>
|
||||
<text>
|
||||
<label>1234</label>
|
||||
<format>%.2f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion-factor/x</property>
|
||||
<enable>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</enable>
|
||||
</text>
|
||||
<slider>
|
||||
<name>distortion-factor-y</name>
|
||||
<min>-0.5</min>
|
||||
<max>0.5</max>
|
||||
<step>0.01</step>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion-factor/y</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>distortion-factor-y</object-name>
|
||||
</binding>
|
||||
<enable>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</enable>
|
||||
</slider>
|
||||
<text>
|
||||
<label>1234</label>
|
||||
<format>%.2f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion-factor/y</property>
|
||||
<enable>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</enable>
|
||||
</text>
|
||||
<slider>
|
||||
<name>distortion-factor-z</name>
|
||||
<min>0.5</min>
|
||||
<max>1.5</max>
|
||||
<step>0.01</step>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion-factor/z</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>distortion-factor-z</object-name>
|
||||
</binding>
|
||||
<enable>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</enable>
|
||||
</slider>
|
||||
<text>
|
||||
<label>1234</label>
|
||||
<format>%.2f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion-factor/z</property>
|
||||
<enable>
|
||||
<property>/sim/rendering/rembrandt/cinema/distortion</property>
|
||||
</enable>
|
||||
</text>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
|
|
|
@ -93,6 +93,12 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<y type="float" userarchive="y">.534</y>
|
||||
<z type="float" userarchive="y">.131</z>
|
||||
</blue-shift>
|
||||
<distortion type="bool">false</distortion>
|
||||
<distortion-factor>
|
||||
<x type="float" userarchive="y">0.0</x>
|
||||
<y type="float" userarchive="y">0.0</y>
|
||||
<z type="float" userarchive="y">1.0</z>
|
||||
</distortion-factor>
|
||||
</cinema>
|
||||
<exposure type="float" userarchive="y">1.0</exposure>
|
||||
<use-color-for-depth type="bool">false</use-color-for-depth>
|
||||
|
|
Loading…
Add table
Reference in a new issue