Support applying outlines to individual objects #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for applying the outline to individual objects. It is not intended to be merged because doing this requires an additional render pass.
To apply the outline on an object, enable it with:
How it works
For reference, here is the original pipeline described here: https://omar-shehata.medium.com/how-to-render-outlines-in-webgl-8253c14724f9
To apply outlines selectively, we need to create normal & depth buffers that ONLY include the outlined object(s). However, the original scene buffer still needs to include all the objects. In addition, the final outline must be occluded by objects in front of it, even if they do not have outlines applied.
My initial approach was to make render pass 2 only include the outlined objects, and use the depth & normal buffers from that. This works and does not add any additional render passes, but the final outline can be "seen through" objects in front it, because then the normal buffer that is used to compute the outlines doesn't include any foreground cubes to occlude it.
To fix this, we add an additional render pass to get a depth buffer with just the objects that do NOT have an outline on them. We then use this to apply a manual depth test in the shader:
The new render pipeline is shown below, including snapshots of what each buffer looks like: