Unity_URP_Rendering Debugger 调试入门之解构环境光反射光等Lit光照模型的代码逻辑
Posted avi9111
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity_URP_Rendering Debugger 调试入门之解构环境光反射光等Lit光照模型的代码逻辑相关的知识,希望对你有一定的参考价值。
目录
同样地不管 fog 的开关,很快就找到 mask lit 开关的 debug 实现
光照模型
明显区分了 mainlit, emission, global等光线
代码代码
还是从 Panel 代码入手
internal void Reset()
m_Settings.Clear();
CommonSettings = Add(new DebugDisplaySettingsCommon());
MaterialSettings = Add(new DebugDisplaySettingsMaterial());
LightingSettings = Add(new DebugDisplaySettingsLighting());
RenderingSettings = Add(new DebugDisplaySettingsRendering());
明显得,各种光照用了mask 做叠加(多选,左移进位)
/// <summary>
/// Debug mode that allows selective disabling of individual lighting components.
/// </summary>
[GenerateHLSL, Flags]
public enum DebugLightingFeatureFlags
/// <summary>The debug mode is not active.</summary>
None,
/// <summary>Display contribution from global illumination.</summary>
GlobalIllumination = 0x1,
/// <summary>Display contribution from the main light.</summary>
MainLight = 0x2,
/// <summary>Display contribution from additional lights.</summary>
AdditionalLights = 0x4,
/// <summary>Display contribution from vertex lighting.</summary>
VertexLighting = 0x8,
/// <summary>Display contribution from emissive objects.</summary>
Emission = 0x10,
/// <summary>Display contribution from ambient occlusion.</summary>
AmbientOcclusion = 0x20,
但,暂时怎么设置 mask 不明显
(之后再补上)
设置 mask 之后,是在哪里注入debug呢?
关键还在于:k_DebugLightingFeatureFlagsId
static readonly int k_DebugLightingFeatureFlagsId = Shader.PropertyToID("_DebugLightingFeatureFlags");
// Lighting settings...
cmd.SetGlobalFloat(k_DebugLightingModeId, (int)LightingSettings.DebugLightingMode);
cmd.SetGlobalInteger(k_DebugLightingFeatureFlagsId, (int)LightingSettings.DebugLightingFeatureFlagsMask);
同样地不管 fog 的开关,很快就找到 mask lit 开关的 debug 实现
in DebuggingCommon.hlsl
bool IsLightingFeatureEnabled(uint bitMask)
#if defined(DEBUG_DISPLAY)
return (_DebugLightingFeatureFlags == 0) || ((_DebugLightingFeatureFlags & bitMask) != 0);
#else
return true;
#endif
分别看看各种光的应用
(这次和DebugColor有点不同,确实是剔除光(分层)了。。。。。)
GI光
if (IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_GLOBAL_ILLUMINATION))
lightingColor += lightingData.giColor;
环境光
if (IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_AMBIENT_OCCLUSION))
bakedGI *= aoFactor.indirectAmbientOcclusion;
以上是关于Unity_URP_Rendering Debugger 调试入门之解构环境光反射光等Lit光照模型的代码逻辑的主要内容,如果未能解决你的问题,请参考以下文章