Conversation
f85c5b3 to
9ec683d
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the URP toon shader’s shadow “tweak” computation to use a shared helper function, and adjusts the KageBall sample scene lighting by grouping lights under a new root and adding a shadow-casting point light.
Changes:
- Add a
TweakShadow(...)helper and replace duplicated_SystemShadowsLevel_varlogic with calls to it. - Update additional-light shadow handling in the shading grade map path (Forward+ path updated; non-Forward+ path partially updated).
- Update the KageBall sample scene hierarchy by adding a
Lightsroot and adding aPoint Light.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
com.unity.toonshader/Samples~/URP/Scenes/KageBall/KageBall.unity |
Adds a Lights parent object and a new point light in the sample scene. |
com.unity.toonshader/Runtime/UniversalRP/Shaders/UniversalToonBodyShadingGradeMap.hlsl |
Refactors shadow tweak calculation to use TweakShadow (but leaves one additional-light path inconsistent). |
com.unity.toonshader/Runtime/UniversalRP/Shaders/UniversalToonBodyDoubleShadeWithFeather.hlsl |
Refactors shadow tweak calculation to use TweakShadow consistently for main/additional lights. |
com.unity.toonshader/Runtime/UniversalRP/Shaders/UniversalToonBody.hlsl |
Adds TweakShadow and updates additional light retrieval to use the 3-arg GetAdditionalLight overload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| float lightIntensity = _LightIntensity; | ||
| float tweakShadows = 1.0 + _Tweak_SystemShadowsLevel; | ||
|
|
||
| float tweakShadows = additionalLight.shadowAttenuation; |
There was a problem hiding this comment.
In the non-Forward+ additional lights loop, tweakShadows is set to additionalLight.shadowAttenuation directly, while the Forward+ path (and main light) now uses TweakShadow(...). This makes shadow response differ depending on whether Forward+ is enabled. Use the same TweakShadow(additionalLight.shadowAttenuation) logic here as well (or intentionally keep raw attenuation in both paths).
| float tweakShadows = additionalLight.shadowAttenuation; | |
| float tweakShadows = TweakShadow(additionalLight.shadowAttenuation); |
| } | ||
|
|
||
| inline float TweakShadow(float shadow) { | ||
| return max((shadow * 0.5) + 0.5 + _Tweak_SystemShadowsLevel, 0.001); |
There was a problem hiding this comment.
TweakShadow is replacing the previous inline _SystemShadowsLevel_var calculation, but it is not equivalent: the old logic clamped values <= 0.001 down to 0.0001, while max(..., 0.001) clamps them up to 0.001. If the goal is a refactor without changing visual output, update TweakShadow to preserve the prior threshold/floor behavior (or document that the minimum shadow tweak has changed).
| return max((shadow * 0.5) + 0.5 + _Tweak_SystemShadowsLevel, 0.001); | |
| float tweakedShadow = (shadow * 0.5) + 0.5 + _Tweak_SystemShadowsLevel; | |
| return (tweakedShadow <= 0.001) ? 0.0001 : tweakedShadow; |
| // index to a perObjectLightIndex | ||
| UtsLight GetAdditionalUtsLight(uint i, float3 positionWS) { | ||
| Light light = GetAdditionalLight(i, positionWS); | ||
| const float shadowMask = 1; |
There was a problem hiding this comment.
shadowMask is introduced to call the 3-arg GetAdditionalLight overload, but it’s declared as a scalar float. URP’s API commonly expects a half4 shadow mask (from baked GI / shadowmask mixing), and using a scalar here relies on implicit splat conversion and makes it harder to later thread through a real shadow mask. Consider changing this to a half4 (e.g., all-ones) and/or plumbing the actual shadow mask from InputData where available.
| const float shadowMask = 1; | |
| const half4 shadowMask = half4(1.0h, 1.0h, 1.0h, 1.0h); |
9ec683d to
969305f
Compare
No description provided.