Skip to content

Experimental Feature: Area Lights#236

Merged
Cameron-Micka merged 49 commits intomicrosoft:mainfrom
Cameron-Micka:user/cameron-micka/area-lights
Mar 26, 2025
Merged

Experimental Feature: Area Lights#236
Cameron-Micka merged 49 commits intomicrosoft:mainfrom
Cameron-Micka:user/cameron-micka/area-lights

Conversation

@Cameron-Micka
Copy link
Copy Markdown
Member

@Cameron-Micka Cameron-Micka commented Mar 25, 2025

Overview

This change introduces a new experimental light type called an AreaLight - area lights allow light to emit from a polygonal surface (quad) rather than a single point. The technique is based off Unity's Adam Demo solution which is based off of this research.

This solution works with the built in or URP's forward renderer. Only two area lights can be rendered at a time, but more than two lights can be added to a scene and the system will automatically cull the least important lights. Area lights are preview-able at edit time just like normal Unity lights.

The AreaLightCookieFilter is a utility component to help "blur" the cookie for an area light. This is helpful for scenarios where the area light's cookie isn't pre-filtered (like a video texture). The AreaLightCookieFilter only works at runtime.

This change also includes a new sample to preview how AreaLights look and behave.
image
image
Screenshot_2025-03-25_11-13-27-AM_9091982fbeacd1f48b06427a76a3d3a5

Tested in editor, and Windows, WebGL, and Android (Quest 2) player builds.
Casting_Screenshot_1742942122890

Note, AreaLights do not currently work with the Graphics Tools/Standard and Graphics Tools/Standard Canvasshaders while performance is evaluated. Examples of how to useAreaLight`s with handwritten shaders and shader graph shaders are included in the sample scene.

Verification

As a reviewer, it is possible to check out this change locally by using the following
commands (substituting {PR_ID} with the ID of this pull request):

git fetch origin pull/{PR_ID}/head:name_of_local_branch

git checkout name_of_local_branch

@Cameron-Micka Cameron-Micka requested a review from Copilot March 25, 2025 23:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Experimental Area Lights feature introduced to enable area light rendering with associated cookie filtering and editor visualization improvements. Key changes include:

  • A new AreaLightInspector for visualizing and interacting with area lights in the editor.
  • An AreaLightCookieFilter component that applies dual blurring to area light cookie textures.
  • Added OnDrawGizmos implementations for various light types and extended AcrylicLayer with an ApplyDualBlur method.

Reviewed Changes

Copilot reviewed 42 out of 56 changed files in this pull request and generated no comments.

Show a summary per file
File Description
com.microsoft.mrtk.graphicstools.unity/Editor/Experimental/AreaLight/AreaLightInspector.cs New inspector for experimental area light with scene visualization.
com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/AreaLightCookieFilter.cs New component to filter cookie textures using dual blurring.
com.microsoft.mrtk.graphicstools.unity/Runtime/Lighting/ProximityLight.cs Added editor gizmo drawing for proximity lights.
com.microsoft.mrtk.graphicstools.unity/Runtime/Lighting/DistantLight.cs Added editor gizmo drawing for distant (directional) lights.
com.microsoft.mrtk.graphicstools.unity/Runtime/Lighting/HoverLight.cs Added editor gizmo drawing for hover lights.
com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/Acrylic/Scripts/AcrylicLayer.cs Extended with a new ApplyDualBlur method for dual blur functionality.
Files not reviewed (14)
  • com.microsoft.mrtk.graphicstools.unity/Editor/Experimental/AreaLight.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Editor/Experimental/AreaLight/AreaLightInspector.cs.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/AreaLight.cs.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/AreaLightCookieFilter.cs.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/AreaLightLUTDisneyDiffuse.cs.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/AreaLightLUTGGX.cs.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/Shaders.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/Shaders/AreaLight.hlsl: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/Shaders/AreaLight.hlsl.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/Shaders/AreaLightSubGraph.shadersubgraph.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/Shaders/AreaLightVisualize.shader: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/Shaders/AreaLightVisualize.shader.meta: Language not supported
  • com.microsoft.mrtk.graphicstools.unity/Samples~/AreaLight.meta: Language not supported
Comments suppressed due to low confidence (2)

com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/AreaLightCookieFilter.cs:121

  • Consider checking that 'cookie' is assigned before accessing its width to avoid potential runtime errors.
int width = cookie.width;

com.microsoft.mrtk.graphicstools.unity/Runtime/Experimental/AreaLight/AreaLightCookieFilter.cs:209

  • [nitpick] Consider using named arguments or adding inline comments for the constructor parameters to improve clarity and readability.
layer = new(null, null, 0, 0, true, null, cookieFilterMaterial);

@Cameron-Micka Cameron-Micka merged commit e4bd67f into microsoft:main Mar 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants