summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-06-07 10:46:37 +0300
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-06-07 10:49:17 +0000
commit4bba1a38897f381412c92d0780b3756ec76cc32b (patch)
tree59f1c6c974767c9642dbcdbb07e571e8ef3ce148
parentb706a87595e471c63220f45fb9df8a00d988acc1 (diff)
Fix image probe FOV calculation
Fix FOV equations. Also, fix case for FOV of 180 degrees where image lighting map was used in wrong orientation. With this fix, the negative z axis passes through the center of the lighting map, with edges of the image wrapped around the scene, i.e. with default camera settings the center of image is in the direction of camera. This holds true for both cases of FOV = 180 and FOV < 180 degrees. This fix must be replicated on editor side for results to match. Task-ID: QT3DS-154 Change-Id: Idb8071dcd74cc3d5b17c964239bec9a52b4fe6b8 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--res/effectlib/sampleProbe.glsllib12
1 files changed, 9 insertions, 3 deletions
diff --git a/res/effectlib/sampleProbe.glsllib b/res/effectlib/sampleProbe.glsllib
index 43024ec..fc40541 100644
--- a/res/effectlib/sampleProbe.glsllib
+++ b/res/effectlib/sampleProbe.glsllib
@@ -97,10 +97,16 @@ vec2 getProbeSampleUV( vec3 smpDir, vec4 probeRot, vec2 probeOfs )
vec2 smpUV;
#if QT3DS_ENABLE_IBL_FOV
- smpUV.x = (2.0 * atan(-smpDir.z, smpDir.x) + 3.14159265358 ) / light_probe_opts.x;
- smpUV.y = (2.0 * atan(-smpDir.z, smpDir.y) + 3.14159265358 ) / light_probe_opts.x;
+ smpUV = vec2(atan(smpDir.x, smpDir.z), asin(smpDir.y));
+ // assume equirectangular HDR spherical map (instead of cube map) and map sample
+ // UV coordinates accordingly
+ smpUV *= 2.0 * vec2(0.1591596371160, 0.318319274232054);
+ // Default FOV is 180 deg = pi rad. Narrow the FOV
+ // by scaling texture coordinates by the ratio of
+ // incoming FOV to 180 degrees default
+ smpUV *= 3.14159265358 / light_probe_opts.x;
#else
- smpUV.x = atan( smpDir.x, -smpDir.z) / 3.14159265359;
+ smpUV.x = atan( smpDir.x, smpDir.z) / 3.14159265359;
smpUV.y = 1.0 - (acos(smpDir.y) / 1.57079632679);
#endif
smpUV = transformSample( smpUV.xy * 0.5, probeRot, probeOfs ) + vec2(0.5, 0.5);