ray_tracing_gltf: Match samplingHemisphere to Ray Tracing Gems implementation and avoid generating directions perpendicular to +z; adjust comments on Lambertian PDF and match docs.

This commit is contained in:
NeilBickford-NV 2023-05-23 14:45:28 -07:00
parent c436c46141
commit 80e00cae4e
3 changed files with 20 additions and 14 deletions

View file

@ -110,12 +110,11 @@ void main()
vec3 rayOrigin = world_position;
vec3 rayDirection = samplingHemisphere(prd.seed, tangent, bitangent, world_normal);
// Compute the BRDF for this ray (assuming Lambertian reflection)
float cos_theta = dot(rayDirection, world_normal);
// Probability of the newRay (cosine distributed)
const float cos_theta = dot(rayDirection, world_normal);
// Probability density function of samplingHemisphere choosing this rayDirection
const float p = cos_theta / M_PI;
// Compute the BRDF for this ray (assuming Lambertian reflection)
vec3 albedo = mat.pbrBaseColorFactor.xyz;
if(mat.pbrBaseColorTexture > -1)
{