-
Notifications
You must be signed in to change notification settings - Fork 855
Add additional APV debug modes #6169
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. |
} | ||
} | ||
|
||
static void ApplyVirtualOffsetsSingleThreaded(Vector3[] positions, out Vector3[] offsets, VirtualOffsetSettings voSettings) |
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.
This and ApplyVirtualOffsets above are kinda stop-gap changes as the current approach is very slow in complex scenes.
There's a separate PR coming that moves this work into bursted jobs while also fixing some offsetting bugs (currently probes are actually pushed inside geometry in certain circumstances), so I've separated them as much as possible.
foreach (MeshRenderer mr in renderComponents) | ||
{ | ||
if (!mr.gameObject.GetComponent<MeshCollider>() && (GameObjectUtility.GetStaticEditorFlags(mr.gameObject).HasFlag(StaticEditorFlags.ContributeGI))) | ||
if ((GameObjectUtility.GetStaticEditorFlags(mr.gameObject) & StaticEditorFlags.ContributeGI) != 0 && !mr.gameObject.TryGetComponent<MeshCollider>(out _)) |
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.
Changed to remove dual allocations from boxing.
} | ||
CleanupOccluders(); | ||
} | ||
ApplyVirtualOffsets(positions, out m_BakingBatch.virtualOffsets); |
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.
This call adds occluders, calculates (and returns) offsets, and cleans up occluders if virtual offset is enabled.
static List<MeshRenderer> addedOccluders; | ||
|
||
private static void AddOccluders() | ||
static void ApplyVirtualOffsets(Vector3[] positions, out Vector3[] offsets) |
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.
Simplify calling code by getting valid offsets output regardless of whether VO is enabled or not.
} | ||
|
||
const int kProbesPerBatch = 1023; | ||
const int kProbesPerBatch = 511; |
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.
The shaders used for drawing instanced probes / offsets are in-fact only capable of drawing 511 instances in a single batch. Breaking them into batches of 1023 effectively means that each batch generates 3 draw calls, hence this change.
Graphics.DrawMeshInstanced(m_DebugMesh, 0, m_DebugMaterial, probeBuffer, probeBuffer.Length, props, ShadowCastingMode.Off, false, 0, camera, LightProbeUsage.Off, null); | ||
} | ||
|
||
if (debugDisplay.drawVirtualOffsetPush) | ||
{ | ||
var offsetBuffer = debug.offsetBuffers[i]; | ||
Graphics.DrawMeshInstanced(m_DebugOffsetMesh, 0, m_DebugOffsetMaterial, offsetBuffer, offsetBuffer.Length, props, ShadowCastingMode.Off, false, 0, camera, LightProbeUsage.Off, null); |
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.
These two DrawMeshInstanced calls don't actually work for me in standalone builds. I'm not sure why, and I didn't have source handy to debug it at time of testing.
I verified that the behaviour is the same in master as well, the draw calls never make it down to the graphics device.
public Vector3[] probePositions; | ||
public Vector3[] offsetVectors; | ||
public SphericalHarmonicsL2[] sh; | ||
public float[] validity; |
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.
Most of this data isn't actually needed at runtime. There's a separate PR coming for separating them.
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.
Validity will be used at runtime :-) Some other things too, offset vectors probably can hide away
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 know that's the plan, but right now it is not used, and I question whether a full float value would make sense anyway for what it represents. (right now the runtime data is quite phat, I think it makes sense to move things as they actually get used)
{ | ||
subdivContainer.children.Add(new DebugUI.FloatField { displayName = "Culling Distance", getter = () => debugDisplay.subdivisionViewCullingDistance, setter = value => debugDisplay.subdivisionViewCullingDistance = value, min = () => 0.0f }); | ||
} | ||
subdivContainer.children.Add(new DebugUI.FloatField { displayName = "Culling Distance", getter = () => debugDisplay.subdivisionViewCullingDistance, setter = value => debugDisplay.subdivisionViewCullingDistance = value, min = () => 0.0f }); |
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.
Why removing the check here?
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.
Because I want to be able to change the culling distance before enabling any debug drawing to avoid my machine grinding to a halt when it defaults to drawing everything.
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.
Adding @iM0ve for 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.
It doesnt work for me. I simply switch from master to the branch and it stops rendering when I enable probes.
Error:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Experimental.Rendering.ProbeReferenceVolume.CreateInstancedProbes () (at D:/Git/Graphics/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Debug.cs:295)
UnityEngine.Experimental.Rendering.ProbeReferenceVolume.DrawProbeDebug (UnityEngine.Camera camera) (at D:/Git/Graphics/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Debug.cs:229)
UnityEngine.Experimental.Rendering.ProbeReferenceVolume.RenderDebug (UnityEngine.Camera camera) (at D:/Git/Graphics/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Debug.cs:74)
UnityEngine.Rendering.HighDefinition.HDRenderPipeline.TryCull (UnityEngine.Camera camera, UnityEngine.Rendering.HighDefinition.HDCamera hdCamera, UnityEngine.Rendering.ScriptableRenderContext renderContext, UnityEngine.Rendering.HighDefinition.SkyManager skyManager, UnityEngine.Rendering.ScriptableCullingParameters cullingParams, UnityEngine.Rendering.HighDefinition.HDRenderPipelineAsset hdrp, UnityEngine.Rendering.HighDefinition.HDRenderPipeline+HDCullingResults& cullingResults) (at D:/Git/Graphics/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs:2366)
UnityEngine.Rendering.HighDefinition.HDRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, System.Collections.Generic.List1[T] cameras) (at D:/Git/Graphics/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs:1311) UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, System.Collections.Generic.List
1[T] cameras) (at <2325cc54de6040309d03768ffdba64e6>:0)
UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, System.Collections.Generic.List`1[T] renderRequests, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety) (at <2325cc54de6040309d03768ffdba64e6>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
@iM0ve fixed the case where data baked before this change would not correctly display debug data unless it's re-baked. |
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.
Testing status: Done
What's tested:
- Visual comparison of baked probes master vs PR. Nothing changed as expected
- Culling distance in Debug menu still works and is moved
- New debug modes
Issues:
- FIXED Ease of use. It's currently difficult to use the debug system out of the box. The arrows are not visible with default settings, often because they're inside of an actual probe. It requires a lot of tweaking to be able to see the arrows, even more if you want to have them in the right proportion to the probes. Maybe it would make sense to have the arrows of relative size to the probes or/and have an offset from the center?
GiM0c322QV.mp4
@iM0ve I agree that it's not necessarily super easy to dial things in, for me there are a couple of reasons for this: The virtual offset as it is in master defaults to fairly small search distance and push offset, and it has a couple of bugs that can often push probes inside instead of away from geometry - this makes some cases all the more confusing. It's hard to know the density / scale users will work at. For me, the default probe size is always too large by a factor of at least ten. For others the opposite might be true. I'm open to suggestion of how to improve this, but IMO the length of the arrow needs to be fixed to the actual offset that has taken place, so that doesn't give you a whole lot of remaining options to work with. Maybe we should default to a smaller with so they more obviously look like arrows? |
@iM0ve added some automatic downscale of probe size if probes are enabled when enabling offset. |
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.
Tested the new UI change. It works better out of the box, The offsets are visible on enabling and you can still resize the probes afterwards if you wish.
Ki9vnyyuaB.mp4
@FrancescoC-unity @sebastienlagarde am I supposed to hit the merge button myself, or will some guardian do that? (provided the DXR test gets in line) |
# Conflicts: # com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs # com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Debug.cs # com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs # com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs
Purpose of this PR
This PR adds a visualization mode for probe placement virtual offset.
An additional toggle has been added for drawing offsets, along with a size slider. The culling distance control has been moved to the bottom and is applied to both probes and offsets visualization. It's also always visible now, so you can reduce the culling distance before enabling drawing.
Offsets are visualized as arrows starting at the probe's grid position and ending at the virtual position of the pushed out probe.
The PR also adds probe volume debug visualizers for displaying probe L0 only and L0L1. This is useful for visualizing the ambient component and for comparing L1 and L2 probes data.
Testing status
Tested that it all works in editor.
Tested that it doesn't break anything in standalone, however since the probe volume debug visualizers already don't work in standalone in master, actually testing the functionality in standalone isn't possible atm.
Comments to reviewers
Storing the virtual offset data with the rest of the baked data bloats the runtime data even more. There is a follow up PR coming that separates runtime data from debug data.
There are inline comments on the commit pointing out various motivations.