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
Universal/light layers #3677
Universal/light layers #3677
Conversation
It appears that you made a non-draft PR! |
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.
@kaychang-unity Thank you for implementing this. I have some questions:
- Are there any risks, performance considerations (including build times), or dependencies involved?
- Are there any other technical areas this has an impact on? (e.g. decals)
- Which platforms is this targeting?
- Does this differ from the HDRP light layers in any way?
- Is documentation planned? @oleks-k
- Which rendering layers are getting exposed as light layers? The first 8?
- Does this mean that some of the 4/8 lights available per object might be wasted due to non matching light layer masks?
- Should this include any analytics?
- Is this feature complete, or is there more that needs to be implemented later?
- Should this be on or off by default?
Regarding your questions:
Should light layer names be renamable by users? They are currently hardcoded.
I think that should be possible, especially since it's possible in HDRP.
Should we add the code related to decals?
How to convert a light culling mask into a light layer?
Hmm, I'm not sure if this is possible. Maybe the HDRP people has some experience with this? @JulienIgnace-Unity
Also, make sure to add the test scene mentioned before this lands :)
com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl
Outdated
Show resolved
Hide resolved
Is this feature supported for OpenGL ES 2.0? |
For this you will need a default settings asset. URP don't have one yet. It come with various workflows. It would be nice to be able to rename light layers, but I will suggest to do it in a separate PR, and then to evaluate if you want to introduce a default settings asset in 21.2 (it have consequence as you need to have it in template etc...).
|
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.
Regarding the change compare to HDRP I am agree with the approach and how it is implemented. But the final decision must come from URP people and take into account URP platform
Co-authored-by: Peter Bay Bastian <pbbastian@users.noreply.github.com>
…hnologies/Graphics into universal/light-layers
I will work on adding a proper test scene. In HDRP, on the HD Render Pipeline Asset in Debug view: Edit: as Seb pointed out, it's possible to rename light layers using default settings asset, which does not exist in URP (leave the renaming feature for another PR). |
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.
Overall looks good to me.
Only a couple of thoughts:
- Light Layer property can be removed from light inspector when light is baked
- Interaction with Shadowmask can give unexpected results. I'm not sure if it is possible for the mask to take light/shadow layers into account but would be nice.
- About renaming light layers: The layer names should be hardcoded as long as URP doesn't have Global Settings
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 seems to work as expected. I was able to play around with the Light Layers in the editor, set different objects to be affected by particular light layers. Rendering on mobile devices looks good too.
Tested using Boat attack and Winter projects.
Winter:
Unity:
Version: 2021.2.0a14.1944
Revision: trunk 9f66320aebca
Built: Fri, 09 Apr 2021 17:39:30 GMT
Devices under testing:
iPad Air4, SoC: A14, iOS: 14.0
iPhone 12Pro, SoC: A14, iOS: 14.1
VLNQA00217, Razer Phone 2, 9.0.0, Snapdragon 845 SDM845, Adreno 630
VLNQA00268, Samsung Galaxy S10+, 10.0.0, Exynos 9 9820, Mali-G76
OnePlus Nord, 10, Snapdragon 765G SM7250-AB, Adreno 620
Samsung Galaxy Z Fold2 5G, 10, Snapdragon 865 SM8250, Adreno 650
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.
Working as expected!
I'm assuming this relates to https://unity3d.atlassian.net/browse/UR-1297. That roadmap item is missing the Product manager approval, so if you could poke the relevant one to sign off, that would be good. Otherwise we risk adding the delay for that approval to the weekly bundling. Other than that I have no complaints. |
…ode does so too). Added missing "instancing_options renderinglayer" to terrain shaders.
…roken on iOS device with light layer shader variant addition.
URP Update top assets is known issue already fixed on master. It's ok to merge with this one red. |
@kaychang-unity wait for test to finish before resolving conflict. Once ABV is green, resolve conflict and don't run test again. looking at conflict file we dont' need to rerun graphics test due to that. |
* Initial light layer support. * Updated changelog. * Auto-formatting. * Update com.unity.render-pipelines.universal/CHANGELOG.md Co-authored-by: Peter Bay Bastian <pbbastian@users.noreply.github.com> * Minor fixes. * Adjusted code to compile out IsMatchingLightLayer() when light layers are disabled (confirmed the code is compiled out on Switch). * Refactoring. Fixed small bug with gbuffer index calculation when shadowMask and lightLayers are enabled. Updated comment for unity_RenderingLayer. * Added test scenes for light layers (148_Lighting_LightLayers and 148_Lighting_LightLayers_deferred). * Formating. * Disable filtering for lightmaps. * Added 148_Lighting_LightLayers and 148_Lighting_LightLayers_deferred in list of scenes to build and test. * AdditionalLightData is now unconditionally created when OnEnable() is called, removed unecessary code to create it when light layers are enabled. * Added some reference images. * Added fake quality level that references UniversalRPAssetLightLayers.asset as a workaround for ShaderPreprocessor otherwise stripping too much. * Moved UI element for light layer mask in Light inspector. Renamed linkLightLayer for shadow to customShadowLayer. * Detect invalid platforms (GLES2) and display error message. * More reference images. * Reference images. * Wait for 2 frames before taking screenshots. This fixes the test scenes failing on Android GLES3. * Reference images. * Tweaked error message. * Removed duplicate assets. * Updated UX to match HDRP. SwapPipelineAsset file redirected to new path. * Fixed null reference in Player mode. * Update com.unity.render-pipelines.universal/Runtime/DeferredLights.cs Fixed typo in comment. Co-authored-by: Felipe Lira <felipedrl@gmail.com> * Added comment. * Moved rendering layer texture from 32 to 8 bits as currently only light layers are stored inside. * A lot of internal renaming from lightLayers to layerMask. * Hide light layers for baked lights. * Fixed formatting to pass yamato format test. * Terrain vertex lit ignores light layers (because default vertex lit code does so too). Added missing "instancing_options renderinglayer" to terrain shaders. * More missing instancing_option renderinglayer. * Temporarily sable 153_Lighting_EnlightenTerrain.unity because it is broken on iOS device with light layer shader variant addition. Co-authored-by: Peter Bay Bastian <pbbastian@users.noreply.github.com> Co-authored-by: Felipe Lira <felipedrl@gmail.com>
Purpose of this PR
This adds support for light layers.
UniversalRenderPipelineAsset has a new checkbox to enable light layers. In this mode, the culling mask property of lights is switched to a light layer property (bitmask). A new shadow layer also appear for the light if it casts shadows.
Testing status
Comments to reviewers
unity_RenderingLayer
are not always correctly set to different meshes. This does not happens anymore with recent trunk revision.