示例#1
0
        public void LayoutShadowMaps(LightingDebugSettings lightingDebugSettings)
        {
            m_Atlas.UpdateDebugSettings(lightingDebugSettings);

            if (m_CascadeAtlas != null)
            {
                m_CascadeAtlas.UpdateDebugSettings(lightingDebugSettings);
            }

            m_AreaLightShadowAtlas.UpdateDebugSettings(lightingDebugSettings);

            if (lightingDebugSettings.shadowResolutionScaleFactor != 1.0f)
            {
                foreach (var shadowResolutionRequest in m_ShadowResolutionRequests)
                {
                    // We don't rescale the directional shadows with the global shadow scale factor
                    // because there is no dynamic atlas rescale when it overflow.
                    if (shadowResolutionRequest.shadowMapType != ShadowMapType.CascadedDirectional)
                    {
                        shadowResolutionRequest.resolution *= lightingDebugSettings.shadowResolutionScaleFactor;
                    }
                }
            }

            // Assign a position to all the shadows in the atlas, and scale shadows if needed
            if (m_CascadeAtlas != null && !m_CascadeAtlas.Layout(false))
            {
                Debug.LogError("Cascade Shadow atlasing has failed, only one directional light can cast shadows at a time");
            }
            m_Atlas.Layout();
            m_AreaLightShadowAtlas.Layout();
        }
示例#2
0
        public void LayoutShadowMaps(LightingDebugSettings lightingDebugSettings)
        {
            m_Atlas.UpdateDebugSettings(lightingDebugSettings);

            if (m_CascadeAtlas != null)
            {
                m_CascadeAtlas.UpdateDebugSettings(lightingDebugSettings);
            }

            m_AreaLightShadowAtlas.UpdateDebugSettings(lightingDebugSettings);

            if (lightingDebugSettings.shadowResolutionScaleFactor != 1.0f)
            {
                foreach (var shadowResolutionRequest in m_ShadowResolutionRequests)
                {
                    shadowResolutionRequest.resolution *= lightingDebugSettings.shadowResolutionScaleFactor;
                }
            }

            // Assign a position to all the shadows in the atlas, and scale shadows if needed
            if (m_CascadeAtlas != null && !m_CascadeAtlas.Layout(false))
            {
                Debug.LogError("Cascade Shadow atlasing has failed, only one directional light can cast shadows at a time");
            }
            m_Atlas.Layout();
            m_AreaLightShadowAtlas.Layout();
        }
示例#3
0
        unsafe public void ProcessShadowRequests(CullResults cullResults, Camera camera, LightingDebugSettings lightingDebugSettings)
        {
            int shadowIndex = 0;

            if (lightingDebugSettings.shadowResolutionScaleFactor != 1.0f)
            {
                foreach (var shadowRequest in m_ShadowRequests)
                {
                    shadowRequest.viewportSize *= lightingDebugSettings.shadowResolutionScaleFactor;
                }
            }

            // Assign a position to all the shadows in the atlas, and scale shadows if needed
            if (!m_CascadeAtlas.Layout(false))
            {
                Debug.LogWarning("Cascade Shadow atlasing has failed, try reducing the shadow resolution of the directional light or increase the shadow atlas size");
            }
            m_Atlas.Layout();

            m_ShadowDatas.Clear();

            // Create all HDShadowDatas and update them with shadow request datas
            foreach (var shadowRequest in m_ShadowRequests)
            {
                m_ShadowDatas.Add(CreateShadowData(shadowRequest));
                shadowRequest.shadowIndex = shadowIndex++;
            }

            int first = k_DirectionalShadowCascadeCount, second = k_DirectionalShadowCascadeCount;

            fixed(float *sphereBuffer = m_DirectionalShadowData.sphereCascades)
            {
                Vector4 *sphere = (Vector4 *)sphereBuffer;

                for (int i = 0; i < k_DirectionalShadowCascadeCount; i++)
                {
                    first  = (first == k_DirectionalShadowCascadeCount && sphere[i].w > 0.0f) ? i : first;
                    second = ((second == k_DirectionalShadowCascadeCount || second == first) && sphere[i].w > 0.0f) ? i : second;
                }
            }

            // Update directional datas:
            if (second != k_DirectionalShadowCascadeCount)
            {
                m_DirectionalShadowData.cascadeDirection = (GetCascadeSphereAtIndex(second) - GetCascadeSphereAtIndex(first)).normalized;
            }
            else
            {
                m_DirectionalShadowData.cascadeDirection = Vector4.zero;
            }

            m_DirectionalShadowData.cascadeDirection.w = k_DirectionalShadowCascadeCount;
        }
        public void LayoutShadowMaps(LightingDebugSettings lightingDebugSettings)
        {
            m_Atlas.UpdateDebugSettings(lightingDebugSettings);

            if (m_CascadeAtlas != null)
            {
                m_CascadeAtlas.UpdateDebugSettings(lightingDebugSettings);
            }

            if (lightingDebugSettings.shadowResolutionScaleFactor != 1.0f)
            {
                foreach (var shadowResolutionRequest in m_ShadowResolutionRequests)
                {
                    shadowResolutionRequest.resolution *= lightingDebugSettings.shadowResolutionScaleFactor;
                }
            }

            // Assign a position to all the shadows in the atlas, and scale shadows if needed
            if (m_CascadeAtlas != null && !m_CascadeAtlas.Layout(false))
            {
                Debug.LogWarning("Cascade Shadow atlasing has failed, try reducing the shadow resolution of the directional light or increase the shadow atlas size");
            }
            m_Atlas.Layout();
        }