I am learning OpenGL from https://learnopengl.com/ . I know how to transform normal(sampled from normal map) from tangent space to world space and why it is necessary in Normal Mapping tutorial .
But in Diffuse irradiance tutorial , it transform a vector from tangent space to world space again!
float sampleDelta = 0.025;
float nrSamples = 0.0;
for(float phi = 0.0; phi < 2.0 * PI; phi += sampleDelta)
{
for(float theta = 0.0; theta < 0.5 * PI; theta += sampleDelta)
{
// spherical to cartesian (in tangent space)
vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
// tangent space to world
vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * N;
irradiance += texture(environmentMap, sampleVec).rgb * cos(theta) * sin(theta);
nrSamples++;
}
}
At this time I don't know why we need to transform the tangentSample
vector .
Besides, in the Specular IBL tutorial , it transform the sampleVector
from tangent space to world space in ImportanceSampleGGX
too !
It seems we need to transform a vector from tangent space to world space when we get it from spherical coordinates to cartesian coordinates ?
The basic answer to your question is that tangent space and world space can't be compared and produce a meaningful result, so if you have a vector in tangent space you have to convert it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.