Skip to content

Instantly share code, notes, and snippets.

View erich666's full-sized avatar

Eric Haines erich666

View GitHub Profile
@pixnblox
pixnblox / shading_position.hlsl
Last active August 14, 2023 13:15
Address the shadow terminator problem by computing a new shading position
// Projects the specified position (point) onto the plane with the specified origin and normal.
float3 projectOnPlane(float3 position, float3 origin, float3 normal)
{
return position - dot(position - origin, normal) * normal;
}
// Computes the shading position of the specified geometric position and vertex positions and
// normals. For a triangle with normals describing a convex surface, this point will be slightly
// above the surface. For a concave surface, the geometry position is used directly.
// NOTE: The difference between the shading position and geometry position is significant when