irtk.connectors.nvdiffrast_connector.prepare_shading_normal¶
- irtk.connectors.nvdiffrast_connector.prepare_shading_normal(pos, view_pos, perturbed_nrm, smooth_nrm, smooth_tng, geom_nrm, two_sided_shading=True, opengl=True)¶
- Takes care of all corner cases and produces a final normal used for shading:
Constructs tangent space
Flips normal direction based on geometric normal for two sided Shading
Perturbs shading normal by normal map
Bends backfacing normals towards the camera to avoid shading artifacts
All tensors assume a shape of [minibatch_size, height, width, 3] or broadcastable equivalent.
- Parameters:
pos – World space g-buffer position.
view_pos – Camera position in world space (typically using broadcasting).
perturbed_nrm – Trangent-space normal perturbation from normal map lookup.
smooth_nrm – Interpolated vertex normals.
smooth_tng – Interpolated vertex tangents.
geom_nrm – Geometric (face) normals.
two_sided_shading – Use one/two sided shading
opengl – Use OpenGL/DirectX normal map conventions
- Returns:
Final shading normal