Skip to content

Custom directional lighting - #37

Merged
Cameron (Cameron-Micka) merged 11 commits into
microsoft:mainfrom
Cameron-Micka:user/cameron-micka/light_masks
Jun 29, 2022
Merged

Cameron (Cameron-Micka) merged 11 commits into
microsoft:mainfrom
Cameron-Micka:user/cameron-micka/light_masks

Conversation

@Cameron-Micka

Copy link
Copy Markdown
Member

Overview

One feature a few users have asked for is "custom directional lighting" especially for UI. Normally this is done with light masks. In URP light masks are cheaper than multiple passes, but looping though all available lights is expensive for mobile stereo devices.

As an alternative a custom directional light (DistantLight) behavior has been made that can be used rather than the default Unity directional light. The shader GUI allows the user to choose if they want to use the current Unity directional light or custom distant light:
image

A DistantLight can be used as a replacement for a Unity DirectionalLight. The main purpose of DistantLights is to recreate important light sources for environments, i.e. the sun or moon. Unity's DirectionalLight is still the default for all new materials.

Example of two spheres, one being lit by a red Unity DirectionalLight and another being lit by a blue DistantLight:
DistantLight

Note, one DistantLight is currently supported alongside the Unity DirectionalLight.

Other improvements include:

  • A new base light type shared amount DistantLight, HoverLight , ProximityLight to remove duplicate implementation
  • Light gizmos now use handles for better editor functionality
  • Fixed a bug in the camera controller which could cause the camera to fly off into infinity (and beyond!)

Changes

Verification

This optional section is a place where you can detail the specific type of verification
you want from reviewers. For example, if you want reviewers to checkout the PR locally
and validate the functionality of specific scenarios, provide instructions
on the specific scenarios and what you want verified.

If there are specific areas of concern or question feel free to highlight them here so
that reviewers can watch out for those issues.

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

@Species521

Martin Wettig (Species521) commented Jun 29, 2022 •

Copy link
Copy Markdown
Contributor

I tried my best to break it, but it works flawlessly. Also DIstantLights and DirectionalLights with similar settings are completely indistinguishable.

image

As expected it integrates well in Unity's object menu and with the other light types, this is a real improvement.
From the artistic perspective this is great, you shall pass :-)

At some point it would be nice to see a detailed performance comparison, but that might be a separate point in the docs later.

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.

Support light masks

2 participants