Skip to content
Merged
Show file tree
Hide file tree
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed couple samplers that had the wrong name in raytracing code
- VFX : Debug material view were rendering pink for albedo. (case 1290752)
- VFX: Fixed LPPV with lit particles in deferred (case 1293608)
- Fixed computation of geometric normal in path tracing (case 1293029).

### Changed
- Removed the material pass probe volumes evaluation mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,15 @@ void GetCurrentIntersectionVertex(AttributeData attributeData, out IntersectionV
#endif
}

// Compute the proper world space geometric normal from the intersected triangle
void GetCurrentIntersectionGeometricNormal(AttributeData attributeData, out float3 geomNormalWS)
{
uint3 triangleIndices = UnityRayTracingFetchTriangleIndices(PrimitiveIndex());
float3 p0 = UnityRayTracingFetchVertexAttribute3(triangleIndices.x, kVertexAttributePosition);
float3 p1 = UnityRayTracingFetchVertexAttribute3(triangleIndices.y, kVertexAttributePosition);
float3 p2 = UnityRayTracingFetchVertexAttribute3(triangleIndices.z, kVertexAttributePosition);

geomNormalWS = normalize(mul(cross(p1 - p0, p2 - p0), (float3x3)WorldToObject3x4()));
}

#endif // UNITY_RAYTRACING_INTERSECTION_INCLUDED
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ void ComputeSurfaceScattering(inout PathIntersection pathIntersection : SV_RayPa
posInput.positionWS = fragInput.positionRWS;
posInput.positionSS = pathIntersection.pixelCoord;

// For path tracing, we want the front-facing test to be performed on the actual geometric normal
float3 geomNormal;
GetCurrentIntersectionGeometricNormal(attributeData, geomNormal);
fragInput.isFrontFace = dot(WorldRayDirection(), geomNormal) < 0.0;

// Build the surfacedata and builtindata
SurfaceData surfaceData;
BuiltinData builtinData;
Expand All @@ -75,7 +80,11 @@ void ComputeSurfaceScattering(inout PathIntersection pathIntersection : SV_RayPa

#ifndef SHADER_UNLIT

// Let's compute the world space position (the non-camera relative one if camera relative rendering is enabled)
// Override the geometric normal (otherwise, it is merely the non-mapped smooth normal)
// Also make sure that it is in the same hemisphere as the shading normal (which may have been flipped)
bsdfData.geomNormalWS = dot(bsdfData.normalWS, geomNormal) > 0.0 ? geomNormal : -geomNormal;

// Compute the world space position (the non-camera relative one if camera relative rendering is enabled)
float3 shadingPosition = fragInput.positionRWS;

// Get current path throughput
Expand Down