Skip to content

[7.x.x Backport] Fixed a performance issue with stochastic ray traced area shadows. #306

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

Merged
merged 2 commits into from
May 5, 2020
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
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 @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed shadowmask UI now correctly showing shadowmask disable
- Fixed the indirect diffuse texture not being ignored when it should (ray tracing disabled).
- Fixed depth prepass and postpass being disabled after changing the shader in the material UI.
- Fixed a performance issue with stochastic ray traced area shadows.

### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// I am not sure why exactly, by a lower epsilon generates ray that even if they give a valid result with ray tracing
// nuke the performance. Changing the epsilon from 1e-6 to 1e-5 seems to solve the issue.
#define PLANE_INTERSECTION_EPSILON 1e-5

bool IntersectPlane(float3 ray_origin, float3 ray_dir, float3 pos, float3 normal, out float t)
{
float denom = dot(normal, ray_dir);
if (abs(denom) > 1e-6)
{
float3 d = pos - ray_origin;
t = dot(d, normal) / denom;
return (t >= 0);
}
return false;
float denom = dot(normal, ray_dir);
if (abs(denom) > PLANE_INTERSECTION_EPSILON)
{
float3 d = pos - ray_origin;
t = dot(d, normal) / denom;
return (t >= 0);
}
return false;
}

struct SphQuad
Expand Down Expand Up @@ -72,7 +76,7 @@ void SphQuadInit(float3 s, float3 ex, float3 ey, float3 o, inout SphQuad squad)
squad.b0 = n0.z;
squad.b1 = n2.z;
squad.b0sq = squad.b0 * squad.b0;
squad.k = 2.0f * PI - g2 - g3;
squad.k = 2.0f * PI - g2 - g3;

// compute solid angle from internal angles
squad.S = g0 + g1 - squad.k;
Expand Down