Skip to content

Decal Layers (Rendering Layers) #6442

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

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open

Conversation

lukaschod
Copy link
Contributor

@lukaschod lukaschod commented Dec 1, 2021

Purpose of this PR

Changing light layers backend into more general rendering layers

  • Adding new texture _CameraRenderingLayersTexture into URP that contains screen space rendering layers of meshes.
  • Adding new class DrawObjectsAndRenderingLayersPass that writes into _CameraRenderingLayersTexture as second render target.
  • Adding new varation of functionality DepthNormalOnlyPass that allows writing into _CameraRenderingLayersTexture as second render target.
  • Changing GBuffer to write into _CameraRenderingLayersTexture instead of light layers now.
  • Added new interanl API for requesting rendering layers ScriptableRendererFeature.RequireRenderingLayers(bool isDeferred, out RenderingLayerUtils.Event atEvent, out RenderingLayerUtils.MaskSize maskSize)

Removing light layers concept from shader backend

Now all logic for comparing layers is done with full rendering layer mask in shaders (C# converts them during the property set). The benefits of this simplifies logic as there is no longer a need to transform rendering layers to light layers when comparing and also avoiding this with decal layers. This should not effect performance as shader always contained them as 32 bit integer. Also this opens a door in the future if we would decide to have rendering layers only in UX side too.

Adding internal API for renderer features to request _CameraRenderingLayersTexture

ScriptableRendererFeature will contain new method internal override bool RequireRenderingLayers(bool isDeferred, out RenderingLayerUtils.Event atEvent, out RenderingLayerUtils.MaskSize maskSize). This will allow URP to know if to produce _CameraRenderingLayersTexture and also at what event. Depending on the event it will be produced either with DepthNormalOnlyPass/DrawObjectPass/GBufferPass.

Decal Layers

Decal Layers implemented with above features and optimized for tiled-renderers. In case of DBuffer DepthNormalOnlyPass used for rendering layers. For Screen Space Forward ForwardOpaquePass provides it and for deferred GBuffer provides it.

New Decal Layers option to control its support in renderer feature:
image

New property in Decal Projector to specify Decal Layer it belongs to:
image


Testing status

  • Tested locally on simple project combinations of DecalLayer/LightLayer/Forward/Deferred/NativeRenderPass/GameView/SceneView/ScreenSpaceDecal/DBuffer/DepthNormalPass.
  • Added automated test 250 to test Rendering Layers. Basically render rendering layer at specific events.
    image
  • Green ABV.
  • Regression Test.

Tiny Presentation

https://docs.google.com/presentation/d/12FzT-Kec55c2IdIXXH24nkI7Ksmb7tzDGWLSDdAcflk/edit#slide=id.g11145254bef_0_43

Technical Design Document

https://docs.google.com/document/d/1Vw6VkHaJkgwwi2_Rv_a98241OaFHsKtm72KuJsIGnJc/edit#


Comments to reviewers

Currently there is idea for removing decal and light layers and keeping only rendering layers for UX too (There is more info in TDD).

@github-actions
Copy link

github-actions bot commented Dec 1, 2021

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.
Link to Yamato: https://unity-ci.cds.internal.unity3d.com/project/902/
Search for your PR branch using the search bar at the top, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

URP
/jobDefinition/.yamato%252Fall-urp.yml%2523PR_URP_trunk
With changes to URP packages, you should also run
/jobDefinition/.yamato%2Fall-lightmapping.yml%23PR_Lightmapping_trunk

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.

@lukaschod lukaschod changed the base branch from universal/staging to master December 1, 2021 15:29
@lukaschod lukaschod force-pushed the universal/decal-layers branch from 72083d9 to 4190446 Compare December 3, 2021 10:11
@@ -63,7 +63,9 @@ Pass
#endif
#if _RENDER_PASS_ENABLED
#define GBUFFER3 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need better way to specify inputs

float EncodeMeshRenderingLayer(uint renderingLayer)
{
// TODO: Expose as property for the size
return PackInt(renderingLayer, 16);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing adding propery that controls size is the best approach here

@lukaschod lukaschod changed the title Universal/decal layers Decal Layers (Rendering Layers) Feb 8, 2022
@@ -153,21 +153,27 @@ internal GraphicsFormat GetGBufferFormat(int index)
else if (index == GBufferShadowMask) // Optional: shadow mask is outputed in mixed lighting subtractive mode for non-static meshes only
return GraphicsFormat.R8G8B8A8_UNorm;
else if (index == GBufferRenderingLayers) // Optional: rendering layers is outputed when light layers are enabled (subset of rendering layers)
return GraphicsFormat.R8_UNorm;
return GraphicsFormat.R16_UNorm;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be controllable

#pragma vertex FullscreenVert
#pragma fragment Fragment
#pragma multi_compile _ _USE_DRAW_PROCEDURAL
#pragma enable_d3d11_debug_symbols
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to comment this enable_d3d11_debug_symbols

…universal/decal-layers

# Conflicts:
#	com.unity.render-pipelines.universal/Editor/GlobalSettings/UniversalRenderPipelineGlobalSettingsUI.Skin.cs
#	com.unity.render-pipelines.universal/Runtime/Decal/DBuffer/DBufferRenderPass.cs
#	com.unity.render-pipelines.universal/Runtime/Passes/ScriptableRenderPass.cs
#	com.unity.render-pipelines.universal/Runtime/RendererFeatures/DecalRendererFeature.cs
#	com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs
@kaychang-unity
Copy link
Contributor

Does ShaderPreprocessor.cs needs to be updated to strip out _WRITE_RENDERING_LAYERS ?

@ernestasKupciunas ernestasKupciunas self-requested a review February 23, 2022 07:16
@lukaschod
Copy link
Contributor Author

Does ShaderPreprocessor.cs needs to be updated to strip out _WRITE_RENDERING_LAYERS ?

Updated

@lukaschod lukaschod marked this pull request as ready for review February 23, 2022 10:28
@lukaschod lukaschod requested a review from a team as a code owner February 23, 2022 10:28
…universal/decal-layers

# Conflicts:
#	TestProjects/UniversalGraphicsTest_Foundation/Assets/CommonAssets/UniversalRPAsset.asset
#	TestProjects/UniversalGraphicsTest_Foundation/ProjectSettings/EditorBuildSettings.asset
#	com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalUnlitSubTarget.cs
#	com.unity.render-pipelines.universal/Runtime/Passes/DrawObjectsPass.cs
#	com.unity.render-pipelines.universal/Runtime/Passes/GBufferPass.cs
@rbechoe
Copy link

rbechoe commented May 18, 2022

Was this ever fully implemented into Unity? I can't find it in the 2021 version(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants