From ebf083823327bde5e32cbddf935d5fd91daa1e66 Mon Sep 17 00:00:00 2001 From: MoCheng Date: Tue, 23 May 2023 11:16:28 +0800 Subject: [PATCH] (fix)fix cos_weight pdf Signed-off-by:mousechannel MoCheng Signed-off-by: MoCheng --- ray_tracing_gltf/shaders/pathtrace.rchit | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ray_tracing_gltf/shaders/pathtrace.rchit b/ray_tracing_gltf/shaders/pathtrace.rchit index 7f8fb74..398176c 100644 --- a/ray_tracing_gltf/shaders/pathtrace.rchit +++ b/ray_tracing_gltf/shaders/pathtrace.rchit @@ -110,12 +110,13 @@ void main() vec3 rayOrigin = world_position; vec3 rayDirection = samplingHemisphere(prd.seed, tangent, bitangent, world_normal); - // Probability of the newRay (cosine distributed) - const float p = 1 / M_PI; - // Compute the BRDF for this ray (assuming Lambertian reflection) float cos_theta = dot(rayDirection, world_normal); - vec3 albedo = mat.pbrBaseColorFactor.xyz; + + // Probability of the newRay (cosine distributed) + const float p = cos_theta / M_PI; + + vec3 albedo = mat.pbrBaseColorFactor.xyz; if(mat.pbrBaseColorTexture > -1) { uint txtId = mat.pbrBaseColorTexture;