internal void UpdateShadowRequest(int index, HDShadowRequest shadowRequest, ShadowMapUpdateType updateType) { if (index >= m_ShadowRequestCount) { return; } m_ShadowRequests[index] = shadowRequest; bool addToCached = updateType == ShadowMapUpdateType.Cached || updateType == ShadowMapUpdateType.Mixed; bool addDynamic = updateType == ShadowMapUpdateType.Dynamic || updateType == ShadowMapUpdateType.Mixed; switch (shadowRequest.shadowMapType) { case ShadowMapType.PunctualAtlas: { if (addToCached) { cachedShadowManager.punctualShadowAtlas.AddShadowRequest(shadowRequest); } if (addDynamic) { m_Atlas.AddShadowRequest(shadowRequest); if (updateType == ShadowMapUpdateType.Mixed) { m_Atlas.AddRequestToPendingBlitFromCache(shadowRequest); } } break; } case ShadowMapType.CascadedDirectional: { m_CascadeAtlas.AddShadowRequest(shadowRequest); break; } case ShadowMapType.AreaLightAtlas: { if (addToCached) { cachedShadowManager.areaShadowAtlas.AddShadowRequest(shadowRequest); } if (addDynamic) { m_AreaLightShadowAtlas.AddShadowRequest(shadowRequest); if (updateType == ShadowMapUpdateType.Mixed) { m_AreaLightShadowAtlas.AddRequestToPendingBlitFromCache(shadowRequest); } } break; } } ; }
internal int ReserveShadowResolutions(Vector2 resolution, ShadowMapType shadowMapType, int lightID, int index, ShadowMapUpdateType updateType) { if (m_ShadowRequestCount >= m_MaxShadowRequests) { Debug.LogWarning("Max shadow requests count reached, dropping all exceeding requests. You can increase this limit by changing the max requests in the HDRP asset"); return(-1); } m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].shadowMapType = shadowMapType; // Note: for cached shadows we manage the resolution requests directly on the CachedShadowAtlas as they need special handling. We however keep incrementing the counter for two reasons: // - Maintain the limit of m_MaxShadowRequests // - Avoid to refactor other parts that the shadow manager that get requests indices from here. if (updateType != ShadowMapUpdateType.Cached || shadowMapType == ShadowMapType.CascadedDirectional) { m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].resolution = resolution; m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].dynamicAtlasViewport.width = resolution.x; m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].dynamicAtlasViewport.height = resolution.y; switch (shadowMapType) { case ShadowMapType.PunctualAtlas: m_Atlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); break; case ShadowMapType.AreaLightAtlas: m_AreaLightShadowAtlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); break; case ShadowMapType.CascadedDirectional: m_CascadeAtlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); break; } } m_ShadowResolutionRequestCounter++; m_ShadowRequestCount = m_ShadowResolutionRequestCounter; return(m_ShadowResolutionRequestCounter - 1); }