High fov Distortion correction
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
7175e646e0
commit
df900a2e46
3 changed files with 215 additions and 0 deletions
44
Compositor/Effects/projection-2d.eff
Normal file
44
Compositor/Effects/projection-2d.eff
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<PropertyList>
|
||||
<name>Effects/Compositor/projection-2d</name>
|
||||
<parameters>
|
||||
<hfov><use>/sim/current-view/field-of-view</use></hfov>
|
||||
<display_xsize>
|
||||
<use>/sim/startup/xsize</use>
|
||||
</display_xsize>
|
||||
<display_ysize>
|
||||
<use>/sim/startup/ysize</use>
|
||||
</display_ysize>
|
||||
</parameters>
|
||||
<technique n="1">
|
||||
<pass>
|
||||
<program>
|
||||
<fragment-shader>Compositor/Shaders/ALS/projection-2d.frag</fragment-shader>
|
||||
</program>
|
||||
<texture-unit>
|
||||
<unit>2</unit>
|
||||
<type>2d</type>
|
||||
</texture-unit>
|
||||
<uniform>
|
||||
<name>display_x</name>
|
||||
<type>int</type>
|
||||
<value><use>display_xsize</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>display_y</name>
|
||||
<type>int</type>
|
||||
<value><use>display_ysize</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>hfov</name>
|
||||
<type>float</type>
|
||||
<value><use>hfov</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>iChannel0</name>
|
||||
<type>sampler-2d</type>
|
||||
<value>2</value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
29
Compositor/Shaders/ALS/projection-2d.frag
Normal file
29
Compositor/Shaders/ALS/projection-2d.frag
Normal file
|
@ -0,0 +1,29 @@
|
|||
// uniforms
|
||||
uniform float hfov;
|
||||
uniform vec2 fg_ViewportSize;
|
||||
uniform sampler2D iChannel0;
|
||||
uniform int display_x;
|
||||
uniform int display_y;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Defines
|
||||
float pi = 3.1415926535897932384626433832795;
|
||||
// Guess vfov based on screen dimensions
|
||||
float vfov = hfov * (fg_ViewportSize.y / fg_ViewportSize.x);
|
||||
|
||||
// Normalize
|
||||
vec2 uv = gl_FragCoord.xy / fg_ViewportSize.xy;
|
||||
// Indicates the position we want on the input
|
||||
vec2 ray = vec2(0.0, 0.0);
|
||||
|
||||
// Correction for the distortion in the original image
|
||||
//ray.y = 0.5 * tan((vfov/180.0) * (uv.y - 0.5) * pi) / tan(0.5 * (vfov/180.0) * pi) + 0.5;
|
||||
ray.y = uv.y;
|
||||
ray.x = 0.5 * tan((hfov/180.0) * (uv.x - 0.5) * pi) / tan(0.5 * (hfov/180.0) * pi) + 0.5;
|
||||
|
||||
// Lookup on the input texture
|
||||
vec4 ret = texture2D( iChannel0, ray.xy );
|
||||
ret.a = 1.0;
|
||||
gl_FragColor = ret;
|
||||
}
|
142
Compositor/als-projection-2d.xml
Normal file
142
Compositor/als-projection-2d.xml
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<PropertyList>
|
||||
<name>ALS</name>
|
||||
|
||||
<buffer>
|
||||
<name>color</name>
|
||||
<type>2d</type>
|
||||
<width>screen</width>
|
||||
<height>screen</height>
|
||||
<format>rgba8</format>
|
||||
</buffer>
|
||||
<buffer>
|
||||
<name>depth</name>
|
||||
<type>2d</type>
|
||||
<width>screen</width>
|
||||
<height>screen</height>
|
||||
<format>depth32f</format>
|
||||
</buffer>
|
||||
<!--buffer>
|
||||
<name>color</name>
|
||||
<type>cubemap</type>
|
||||
<width>2048</width>
|
||||
<height>2048</height>
|
||||
<format>rgba8</format>
|
||||
</buffer>
|
||||
<buffer>
|
||||
<name>depth</name>
|
||||
<type>cubemap</type>
|
||||
<width>2048</width>
|
||||
<height>2048</height>
|
||||
<format>depth32f</format>
|
||||
</buffer-->
|
||||
<buffer>
|
||||
<name>sun-shadowmap-atlas</name>
|
||||
<type>2d</type>
|
||||
<width><property>/sim/rendering/als/shadows/sun-atlas-size</property></width>
|
||||
<height><property>/sim/rendering/als/shadows/sun-atlas-size</property></height>
|
||||
<format>depth32f</format>
|
||||
<wrap-s>clamp-to-border</wrap-s>
|
||||
<wrap-t>clamp-to-border</wrap-t>
|
||||
<wrap-r>clamp-to-border</wrap-r>
|
||||
<min-filter>linear</min-filter>
|
||||
<mag-filter>linear</mag-filter>
|
||||
<border-color type="vec4d">1.0 1.0 1.0 1.0</border-color>
|
||||
<shadow-comparison>true</shadow-comparison>
|
||||
</buffer>
|
||||
|
||||
|
||||
<!-- Shadow mapping pre-passes -->
|
||||
<pass include="ALS/csm.xml">
|
||||
<name>csm0</name>
|
||||
<near-m>0.1</near-m>
|
||||
<far-m>3.0</far-m>
|
||||
<viewport>
|
||||
<x>0.0</x>
|
||||
<y>0.0</y>
|
||||
<width>0.5</width>
|
||||
<height>0.5</height>
|
||||
</viewport>
|
||||
</pass>
|
||||
<pass include="ALS/csm.xml">
|
||||
<name>csm1</name>
|
||||
<near-m>3.0</near-m>
|
||||
<far-m>50.0</far-m>
|
||||
<viewport>
|
||||
<x>0.5</x>
|
||||
<y>0.0</y>
|
||||
<width>0.5</width>
|
||||
<height>0.5</height>
|
||||
</viewport>
|
||||
</pass>
|
||||
<pass include="ALS/csm.xml">
|
||||
<name>csm2</name>
|
||||
<near-m>50.0</near-m>
|
||||
<far-m>150.0</far-m>
|
||||
<viewport>
|
||||
<x>0.0</x>
|
||||
<y>0.5</y>
|
||||
<width>0.5</width>
|
||||
<height>0.5</height>
|
||||
</viewport>
|
||||
</pass>
|
||||
<pass include="ALS/csm.xml">
|
||||
<name>csm3</name>
|
||||
<near-m>150.0</near-m>
|
||||
<far-m>1500.0</far-m>
|
||||
<viewport>
|
||||
<x>0.5</x>
|
||||
<y>0.5</y>
|
||||
<width>0.5</width>
|
||||
<height>0.5</height>
|
||||
</viewport>
|
||||
</pass>
|
||||
|
||||
<pass>
|
||||
<name>forward</name>
|
||||
<type>scene</type>
|
||||
<effect-scheme>als-lighting</effect-scheme>
|
||||
|
||||
<clustered-shading>
|
||||
<tile-size>128</tile-size>
|
||||
<num-threads>1</num-threads>
|
||||
<depth-slices>1</depth-slices>
|
||||
</clustered-shading>
|
||||
|
||||
<use-shadow-pass>csm0</use-shadow-pass>
|
||||
<use-shadow-pass>csm1</use-shadow-pass>
|
||||
<use-shadow-pass>csm2</use-shadow-pass>
|
||||
<use-shadow-pass>csm3</use-shadow-pass>
|
||||
|
||||
<!--cubemap-face>5</cubemap-face-->
|
||||
|
||||
<binding>
|
||||
<buffer>sun-shadowmap-atlas</buffer>
|
||||
<unit>10</unit>
|
||||
</binding>
|
||||
|
||||
<attachment>
|
||||
<buffer>color</buffer>
|
||||
<component>color0</component>
|
||||
<multisample-samples>4</multisample-samples>
|
||||
<multisample-color-samples>4</multisample-color-samples>
|
||||
</attachment>
|
||||
<attachment>
|
||||
<buffer>depth</buffer>
|
||||
<component>depth</component>
|
||||
<multisample-samples>4</multisample-samples>
|
||||
<multisample-color-samples>4</multisample-color-samples>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
||||
<pass>
|
||||
<name>display</name>
|
||||
<type>quad</type>
|
||||
<binding>
|
||||
<buffer>color</buffer>
|
||||
<unit>2</unit>
|
||||
</binding>
|
||||
<effect>Compositor/Effects/projection-2d</effect>
|
||||
</pass>
|
||||
</PropertyList>
|
Loading…
Reference in a new issue