From ad712ce1cebf3e88cf3c00a78aa8d2dc2ecbd8ef Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 1 Aug 2024 01:09:35 +0900 Subject: [PATCH] fix emission internal flag --- .../IO/MaterialIO/URP/ShaderUtil/Lit/UrpLitContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/ShaderUtil/Lit/UrpLitContext.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/ShaderUtil/Lit/UrpLitContext.cs index bc5fd3d7b..5d68f0558 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/ShaderUtil/Lit/UrpLitContext.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/URP/ShaderUtil/Lit/UrpLitContext.cs @@ -39,7 +39,6 @@ namespace UniGLTF private static readonly int SpecGlossMapProp = Shader.PropertyToID("_SpecGlossMap"); private static readonly int BumpScaleProp = Shader.PropertyToID("_BumpScale"); private static readonly int BumpMapProp = Shader.PropertyToID("_BumpMap"); - private static readonly int EmissionEnabled = Shader.PropertyToID("_EmissionEnabled"); private static readonly int ZWrite = Shader.PropertyToID("_ZWrite"); private static readonly int SrcBlend = Shader.PropertyToID("_SrcBlend"); private static readonly int DstBlend = Shader.PropertyToID("_DstBlend"); @@ -218,8 +217,15 @@ namespace UniGLTF get => _mat.IsKeywordEnabled(EmissionKeyword); set { - _mat.SetFloat(EmissionEnabled, value ? 1.0f : 0.0f); _mat.SetKeyword(EmissionKeyword, value); + if (value) + { + _mat.globalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack; + } + else + { + _mat.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack; + } } }