-
Notifications
You must be signed in to change notification settings - Fork 855
[HDRP] Implement conservative voxelization for APV #6473
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
Conversation
Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed. HDRP SRP Core Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure. |
Because this can lead to more probes we should add this as an option (ON by default probably, but turn offable regardless) |
Don't forget the changelog 👍 |
var go = renderer.component.gameObject; | ||
int rendererLayerMask = 1 << go.layer; | ||
renderer.volume.CalculateCenterAndSize(out _, out var rendererBoundsSize); | ||
float rendererBoundsVolume = rendererBoundsSize.x * rendererBoundsSize.y * rendererBoundsSize.z; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid issues with planes I'd say we should min all dimensions to avoid 0, probably to 2/3 cm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in this renderer size, there is already padding of 1cm in every axis
internal static readonly GUIContent s_ObjectLayerMask = new GUIContent("Layer Mask", "Control which layers will be used to select the meshes for the probe placement algorithm."); | ||
internal static readonly GUIContent s_GeometryDistanceOffset = new GUIContent("Probe Placement Distance Offset", "Affects the minimum distance at which the subdivision system will attempts to place probes near the geometry. This value can be useful in situations where the generated probes don't fully cover an object."); | ||
internal static readonly GUIContent s_MinRendererVolumeSize = new GUIContent("Minimum Renderer Volume Size", "Specifies the minimum bounding box volume of renderers to consider placing probes around."); | ||
internal static readonly GUIContent s_OverrideMinRendererVolumeSize = new GUIContent("Override Renderer Filters", "Overrides the Minimum Renderer Volume Size specified in the Probe Volume Settings Window."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this
Override Renderer Filters
Should have been Minimum Renderer Volume Size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Override Minimum Renderer Volume Size
Was too long in the inspector, needed to find another name
# Conflicts: # com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM waiting for QA testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't ran into any issues. Changes look good to me!
What I've checked:
- Renderer Filter Settings - Layer Mask
- Renderer Filter Settings - Minimum Renderer Volume Size, smaller objects are correctly ignored
- Bounding Box Of 0.5x0.5x0.5 - bricks are shown with Min Renderer Volume Size up to 0.13
- Bounding Box Of 1x1x1 - bricks are shown with Min Renderer Volume Size up to 1.03
- Bounding Box Of 5x5x5 - bricks are shown with Min Renderer Volume Size up to 125
- Bounding Box Of 5x10x50 - bricks are shown with Min Renderer Volume Size up to 2500
- Overlapping bounding boxes - overlap is ignored, setting only checks for individual renderer bounding boxes
- Multiple local volumes with different settings
- Complex shapes
- Different Max Distance Between Probes settings
- Probe comparison between master and PR in Classroom project - looks nearly identical
I could try to see if I can add one in. Although do we have a way to visualize probe volume subdivision levels debug mode in Graphics Test? We have a Debug View Controller script in use for some scenes, but it seems to support only Materials, Lighting and Rendering section, will need to dig into it how to get that extended. |
It'd be cool, the problem is that it'd also be fairly slow as we'd need to retrigger the baking. Although I guess we can have a scene with realtime subdivision enabled, that won't be too slow. With realtime subdiv and no asset assigned in the scene (no baking ever triggered), it should work, no @alelievr ? |
This reverts commit 1fe51a8. # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md
Purpose of this PR
This PR improves the behavior of the voxelization used to place probes for APV when dealing with small objects.
The problem was that when an object is smaller than a brick (3 x min probe distance) it could be ignored by the probe placement system, this is caused by the rasterization of objects and can be solved by enabling conservative rasterization
There is also a small bugfix about cell position not being correct when enabling realtime voxelization
Replaced the geometry distance offset since it's not necessary anymore with the conservative rasterization and added a new field called "Minimum Renderer Volume Size" to ignore small renderers when placing probes.
You can override this new field per probe volume or set it globally in the baking set:


When the bounding box volume of a renderer in a probe volume is smaller than the value of this field, then the renderer is discarded from the list of objects to place probes around
Added a new LayerMask field in the APV window and an override on the probe volume component instead of only being able to set it on the probe volume.
technical details
The main issue with conservative rasterization is that it's not made to work in 3D and causes extreme artifacts when directly writing to a UAV in a fragment. There is no good solution for this as it's expected that conservative rasterization gives "bad" results for fragment interpolated values, especially when the triangle is close to being degenerate. So the only solution I found was to discard voxels written outside of the bounding box of the current rasterized triangle (this is done with a geometry shader, it's not optimal but still better than writing a software rasterizer in compute).
Note that in some cases this implementation can lead to false positives and generate more probes than before (especially in scenes with very large triangular shapes).
Testing status
Without conservative voxelization
WithoutConservative.mp4
With conservative voxelization
WithConservative.mp4
Minimum renderers size feature:
Renderers.volume.size.mp4