예제 #1
0
        public void OnValidate()
        {
            if (m_Handle != null) // don't do anything if OnEnable hasn't been called yet when scene is loading.
            {
                Vector4   uvScaleBias = new Vector4(m_UVScale.x, m_UVScale.y, m_UVBias.x, m_UVBias.y);
                Matrix4x4 sizeOffset  = Matrix4x4.Translate(m_Offset) * Matrix4x4.Scale(m_Size);
                // handle material changes, because decals are stored as sets sorted by material, if material changes decal needs to be removed and re-added to that it goes into correct set
                if (m_OldMaterial != m_Material)
                {
                    DecalSystem.instance.RemoveDecal(m_Handle);
                    m_Handle      = DecalSystem.instance.AddDecal(transform, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material);
                    m_OldMaterial = m_Material;

                    // notify the editor that material has changed so it can update the shader foldout
                    if (OnMaterialChange != null)
                    {
                        OnMaterialChange();
                    }
                }
                else // no material change, just update whatever else changed
                {
                    DecalSystem.instance.UpdateCachedData(transform, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle);
                }
            }

            if (m_Material != null)
            {
                Shader shader = m_Material.shader;
                if ((shader != null) && (shader.name != "HDRP/Decal"))
                {
                    Debug.LogWarning("Decal projector component material is not using HDRP/Decal shader.", this);
                }
            }
        }
예제 #2
0
        public void OnValidate()
        {
            // handle material changes
            if (m_OldMaterial != m_Material)
            {
                if (m_Handle != null)
                {
                    DecalSystem.instance.RemoveDecal(m_Handle);
                }
                Vector4 uvScaleBias = new Vector4(m_UVScale.x, m_UVScale.y, m_UVBias.x, m_UVBias.y);
                m_Handle      = DecalSystem.instance.AddDecal(transform, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material);
                m_OldMaterial = m_Material;

                // notify the editor that material has changed so it can update the shader foldout
                if (OnMaterialChange != null)
                {
                    OnMaterialChange();
                }
            }

            if (m_Material != null)
            {
                Shader shader = m_Material.shader;
                if ((shader != null) && (shader.name != "HDRenderPipeline/Decal"))
                {
                    Debug.LogWarning("Decal projector component material is not using HDRenderPipeline/Decal shader.", this);
                }
            }
        }
예제 #3
0
        public void OnValidate()
        {
            if (m_Handle != null) // don't do anything if OnEnable hasn't been called yet when scene is loading.
            {
                Matrix4x4 sizeOffset = Matrix4x4.Translate(offset) * Matrix4x4.Scale(size);
                // handle material changes, because decals are stored as sets sorted by material, if material changes decal needs to be removed and re-added to that it goes into correct set
                if (m_OldMaterial != m_Material)
                {
                    DecalSystem.instance.RemoveDecal(m_Handle);
                    m_Handle      = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, m_FadeFactor);
                    m_OldMaterial = m_Material;

                    if (!DecalSystem.IsHDRenderPipelineDecal(m_Material.shader.name)) // non HDRP/decal shaders such as shader graph decal do not affect transparency
                    {
                        m_AffectsTransparency = false;
                    }

                    // notify the editor that material has changed so it can update the shader foldout
                    if (OnMaterialChange != null)
                    {
                        OnMaterialChange();
                    }
                }
                else // no material change, just update whatever else changed
                {
                    DecalSystem.instance.UpdateCachedData(position, rotation, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle, gameObject.layer, m_FadeFactor);
                }
            }
        }
예제 #4
0
 public void OnDisable()
 {
     if (m_Handle != null)
     {
         DecalSystem.instance.RemoveDecal(m_Handle);
         m_Handle = null;
     }
 }
예제 #5
0
        public void OnEnable()
        {
            if (m_Material == null)
            {
                var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
                m_Material = hdrp != null?hdrp.GetDefaultDecalMaterial() : null;
            }

            if (m_Handle != null)
            {
                DecalSystem.instance.RemoveDecal(m_Handle);
            }
            m_Handle = DecalSystem.instance.AddDecal(transform, m_DrawDistance, m_FadeScale, m_Material);
        }
예제 #6
0
        public void OnEnable()
        {
            if (m_Material == null)
            {
                var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
                m_Material = hdrp != null?hdrp.GetDefaultDecalMaterial() : null;
            }

            if (m_Handle != null)
            {
                DecalSystem.instance.RemoveDecal(m_Handle);
                m_Handle = null;
            }

            Vector4 uvScaleBias = new Vector4(m_UVScale.x, m_UVScale.y, m_UVBias.x, m_UVBias.y);

            m_Handle = DecalSystem.instance.AddDecal(transform, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material);
        }
예제 #7
0
        public void OnEnable()
        {
            if (m_Material == null)
            {
#if UNITY_EDITOR
                var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
                m_Material = hdrp != null?hdrp.GetDefaultDecalMaterial() : null;
#else
                m_Material = null;
#endif
            }

            if (m_Handle != null)
            {
                DecalSystem.instance.RemoveDecal(m_Handle);
                m_Handle = null;
            }

            Matrix4x4 sizeOffset = Matrix4x4.Translate(offset) * Matrix4x4.Scale(size);
            m_Handle = DecalSystem.instance.AddDecal(position, rotation, Vector3.one, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material, gameObject.layer, m_FadeFactor);
        }
예제 #8
0
        public void OnEnable()
        {
            if (m_Material == null)
            {
#if UNITY_EDITOR
                var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
                m_Material = hdrp != null?hdrp.GetDefaultDecalMaterial() : null;
#else
                m_Material = null;
#endif
            }

            if (m_Handle != null)
            {
                DecalSystem.instance.RemoveDecal(m_Handle);
                m_Handle = null;
            }

            Vector4   uvScaleBias = new Vector4(m_UVScale.x, m_UVScale.y, m_UVBias.x, m_UVBias.y);
            Matrix4x4 sizeOffset  = Matrix4x4.Translate(m_Offset) * Matrix4x4.Scale(m_Size);
            m_Handle = DecalSystem.instance.AddDecal(transform, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material);
        }