Hello,
I have a problem regarding z axis direction when presenting specular IBL. Notice that z direction is inverted and image presented to user is alongside his view.
float4 main(PixelInputType input) : SV_TARGET
{
input.normal = normalize(input.normal);
input.tangent = normalize(input.tangent);
input.binormal = normalize(input.binormal);
float3x3 TBN = transpose(float3x3(input.tangent, input.binormal, input.normal));
float3 N = normalTexture.Sample(baseSampler, input.uv).rgb * 2.0 - 1.0;
N = normalize(mul(TBN, N));
const float3 V = normalize(input.viewDir.xyz);
const float NoV = abs(dot(N, V)) + 0.0001f; //avoid artifact - as in Frostbite
const float3 R = 2.0 * NoV * N - V;
const float3 prefilteredSpecular = specularIBLTexture.SampleLevel(baseSampler, R, roughness * 5.0);
return float4(prefilteredSpecular, 1.0f);
}
Where input.viewDir is defined in VS as and g_viewerPosition is camera position in world space.
float4 positionWS = mul(output.position, worldMatrix);
output.viewDir.xyz = normalize(g_viewerPosition.xyz - positionWS.xyz);