diff options
author | Janne Kangas <janne.kangas@qt.io> | 2018-06-06 10:09:01 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2018-06-07 11:22:37 +0000 |
commit | 59a1ffa657c989d0aa270625d39b95f850b609b3 (patch) | |
tree | e3ad0d6543385350d7051b6bb3e0b130dee1ca35 | |
parent | 6410d06e18f2cd0dc17abe3b2eac69fa70c3ee11 (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 runtime side for results to match.
Task-ID: QT3DS-154
Change-Id: I917f4f1897e59294aa369933fc9b10ae849952e6
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
-rw-r--r-- | src/Runtime/res/effectlib/sampleProbe.glsllib | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Runtime/res/effectlib/sampleProbe.glsllib b/src/Runtime/res/effectlib/sampleProbe.glsllib index 43024ec3..6556e51c 100644 --- a/src/Runtime/res/effectlib/sampleProbe.glsllib +++ b/src/Runtime/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 warp 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); |