【发布时间】:2019-10-26 01:10:16
【问题描述】:
我正在向https://learnopengl.com/ 学习 OpenGL。我知道如何将法线(从法线贴图采样)从切线空间转换为世界空间,以及为什么在Normal Mapping tutorial 中需要它。
但是在Diffuse irradiance tutorial 中,它又将一个向量从切线空间转换到了世界空间!
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++;
}
}
此时我不知道为什么我们需要对tangentSample向量进行变换。
此外,在Specular IBL tutorial 中,它还将sampleVector 从切线空间转换为ImportanceSampleGGX 中的世界空间!
当我们从球坐标到笛卡尔坐标时,似乎我们需要将向量从切线空间转换到世界空间?
【问题讨论】: