Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3D12RaytracingSimpleLighting bug fix #888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ inline void GenerateCameraRay(uint2 index, out float3 origin, out float3 directi
// Diffuse lighting calculation.
float4 CalculateDiffuseLighting(float3 hitPosition, float3 normal)
{
float3x3 o2w = (float3x3)ObjectToWorld3x4();
float3 normalWorldSpace = normalize(mul(o2w, normal));
float3 pixelToLight = normalize(g_sceneCB.lightPosition.xyz - hitPosition);

// Diffuse contribution.
float fNDotL = max(0.0f, dot(pixelToLight, normal));
float fNDotL = max(0.0f, dot(pixelToLight, normalWorldSpace));

return g_cubeCB.albedo * g_sceneCB.lightDiffuseColor * fNDotL;
}
Expand Down