microsoft / MixedReality-GraphicsTools-Unity

Graphics tools and components for developing Mixed Reality applications in Unity.
MIT License
182 stars 42 forks source link

#55 Add Shadow function #133

Closed HoloMoto closed 1 year ago

HoloMoto commented 1 year ago

Overview

Added the ability to receive shadows to StandardShader.

The Buildin pipeline could not find any other way to receive shadows other than to add a Pass, and for these reasons we have made it URP-only once. Also, unlike the method described in #55, I did not use a RendererFeature, but instead completed it in the Shader.  I am still learning, so there may be places where I am forcing things. If you have any suggestions for improvement, let me know!

Changes

55

The changes are in the following file.

com.microsoft.mrtk.graphicstools.unity/Editor/ShaderGUIs/StandardShaderGUI.cs

Allows display of _RECEIVESHADOW parameters.

com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/GraphicsToolsLighting.hlsl

What I have done is to allow shadowCoord to be passed as an argument to GTGetMainLight in order to use the shadowCoord provided in URP's RealtimeLighting.hlsl.

com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/GraphicsToolsStandard.shader

Add new parameter [Toggle(_RECEIVESHADOW)] _ReceiveShadow("ReceiveShadow",Float) =0.0

com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/GraphicsToolsStandardCanvas.shader

Parameters have been added to the StandardShaderGUI.cs with the changes.

com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/GraphicsToolsStandardInput.hlsl

add half4 shadowCoord : TEXCOORD4;

com.microsoft.mrtk.graphicstools.unity/Runtime/Shaders/GraphicsToolsStandardProgram.hlsl

Cameron-Micka commented 1 year ago

@HoloMoto & @pinkwerks, just a FYI, I merged the shadow casting PR #146 into main.

HoloMoto commented 1 year ago

@Cameron-Micka @pinkwerks Sorry I haven't been able to work on it at all.

I have some conflicts with #146 here, so I would like to import the main branch into the main branch and work on it. I checked the fb you gave me just the day before yesterday.  I'll rename it and make some adjustments!

Cameron-Micka commented 1 year ago

Closing this for now - we can revisit this when time allows!