Hi, I just read through chapters 10 and 11 and in the PBR.metal shader the view direction is calculated as
float3 viewDirection = normalize(params.cameraPosition);
Seems to me like this will only be correct if the pixel’s worldPosition is at the origin, which given that most examples are just rendering models at the origin, is a working approximation, but if the model was moved wouldn’t this be incorrect?
Looking at later sample code it looks like IBL.metal calculates it as
float3 viewDirection =
in.worldPosition.xyz - params.cameraPosition;
Which is what I would assume is correct (but inverted?)
Shouldn’t PBR.metal also be calculating the viewDirection in a similar way, i.e. as the vector from the worldPosition to the cameraPosition, not just the origin to the cameraPosition, or have I missed something?
Also I just want to say I love the book.