Example #1
0
 static void Drawer_SectionCookies(SerializedHDRenderPipelineAsset serialized, Editor owner)
 {
     EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.cookieSize, k_CoockieSizeContent);
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize, k_CookieTextureArraySizeContent);
     if (EditorGUI.EndChangeCheck())
     {
         serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
     }
     if (serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.hasMultipleDifferentValues)
     {
         EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
     }
     else
     {
         long currentCache = TextureCache2D.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.intValue, serialized.renderPipelineSettings.lightLoopSettings.cookieSize.intValue, 1);
         if (currentCache > HDRenderPipeline.k_MaxCacheSize)
         {
             int    reserved = TextureCache2D.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.cookieSize.intValue, 1);
             string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
             EditorGUILayout.HelpBox(message, MessageType.Error);
         }
         else
         {
             string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
             EditorGUILayout.HelpBox(message, MessageType.Info);
         }
     }
     EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize, k_PointCoockieSizeContent);
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize, k_PointCookieTextureArraySizeContent);
     if (EditorGUI.EndChangeCheck())
     {
         serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
     }
     if (serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.hasMultipleDifferentValues)
     {
         EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
     }
     else
     {
         long currentCache = TextureCacheCubemap.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.intValue, serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize.intValue, 1);
         if (currentCache > HDRenderPipeline.k_MaxCacheSize)
         {
             int    reserved = TextureCacheCubemap.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize.intValue, 1);
             string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
             EditorGUILayout.HelpBox(message, MessageType.Error);
         }
         else
         {
             string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
             EditorGUILayout.HelpBox(message, MessageType.Info);
         }
     }
 }
Example #2
0
 public void Cleanup()
 {
     if (m_DecalAtlas != null)
     {
         m_DecalAtlas.Release();
     }
     CoreUtils.Destroy(m_DecalMesh);
     // set to null so that they get recreated
     m_DecalAtlas = null;
     m_DecalMesh  = null;
 }
Example #3
0
 public void Release()
 {
     if (m_TextureCache != null)
     {
         m_TextureCache.Release();
         m_TextureCache = null;
     }
     if (m_TempRenderTexture != null)
     {
         m_TempRenderTexture.Release();
         m_TempRenderTexture = null;
     }
     m_ProbeBakingState = null;
 }
Example #4
0
        public PlanarReflectionProbeCache(IBLFilterGGX iblFilter, int cacheSize, int probeSize, TextureFormat probeFormat, bool isMipmaped)
        {
            // BC6H requires CPP feature not yet available
            probeFormat = TextureFormat.RGBAHalf;

            Debug.Assert(probeFormat == TextureFormat.BC6H || probeFormat == TextureFormat.RGBAHalf, "Reflection Probe Cache format for HDRP can only be BC6H or FP16.");

            m_ProbeSize    = probeSize;
            m_CacheSize    = cacheSize;
            m_TextureCache = new TextureCache2D();
            m_TextureCache.AllocTextureArray(cacheSize, probeSize, probeSize, probeFormat, isMipmaped);
            m_IBLFilterGGX = iblFilter;

            m_PerformBC6HCompression = probeFormat == TextureFormat.BC6H;

            InitializeProbeBakingStates();
        }
        static void Drawer_SectionCookies(GlobalLightLoopSettingsUI s, SerializedGlobalLightLoopSettings d, Editor o)
        {
            EditorGUILayout.PropertyField(d.cookieSize, _.GetContent("Cookie Size"));
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(d.cookieTexArraySize, _.GetContent("Texture Array Size"));
            if (EditorGUI.EndChangeCheck())
            {
                d.cookieTexArraySize.intValue = Mathf.Clamp(d.cookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
            }
            long currentCache = TextureCache2D.GetApproxCacheSizeInByte(d.cookieTexArraySize.intValue, d.cookieSize.intValue);

            if (currentCache > LightLoop.k_MaxCacheSize)
            {
                int    reserved = TextureCache2D.GetMaxCacheSizeForWeightInByte(LightLoop.k_MaxCacheSize, d.cookieSize.intValue);
                string message  = string.Format(cacheErrorFormat, HumanizeWeight(currentCache), reserved);
                EditorGUILayout.HelpBox(message, MessageType.Error);
            }
            else
            {
                string message = string.Format(cacheInfoFormat, HumanizeWeight(currentCache));
                EditorGUILayout.HelpBox(message, MessageType.Info);
            }
            EditorGUILayout.PropertyField(d.pointCookieSize, _.GetContent("Point Cookie Size"));
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(d.cubeCookieTexArraySize, _.GetContent("Cubemap Array Size"));
            if (EditorGUI.EndChangeCheck())
            {
                d.cubeCookieTexArraySize.intValue = Mathf.Clamp(d.cubeCookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
            }
            currentCache = TextureCacheCubemap.GetApproxCacheSizeInByte(d.cubeCookieTexArraySize.intValue, d.pointCookieSize.intValue);
            if (currentCache > LightLoop.k_MaxCacheSize)
            {
                int    reserved = TextureCacheCubemap.GetMaxCacheSizeForWeightInByte(LightLoop.k_MaxCacheSize, d.pointCookieSize.intValue);
                string message  = string.Format(cacheErrorFormat, HumanizeWeight(currentCache), reserved);
                EditorGUILayout.HelpBox(message, MessageType.Error);
            }
            else
            {
                string message = string.Format(cacheInfoFormat, HumanizeWeight(currentCache));
                EditorGUILayout.HelpBox(message, MessageType.Info);
            }
            EditorGUILayout.Space();
        }
        static void Drawer_SectionCookies(SerializedGlobalLightLoopSettings serialized, Editor owner)
        {
            EditorGUILayout.PropertyField(serialized.cookieSize, k_CoockieSizeContent);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.cookieTexArraySize, k_CookieTextureArraySizeContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.cookieTexArraySize.intValue = Mathf.Clamp(serialized.cookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
            }
            long currentCache = TextureCache2D.GetApproxCacheSizeInByte(serialized.cookieTexArraySize.intValue, serialized.cookieSize.intValue, 1);

            if (currentCache > LightLoop.k_MaxCacheSize)
            {
                int    reserved = TextureCache2D.GetMaxCacheSizeForWeightInByte(LightLoop.k_MaxCacheSize, serialized.cookieSize.intValue, 1);
                string message  = string.Format(k_CacheErrorFormat, HumanizeWeight(currentCache), reserved);
                EditorGUILayout.HelpBox(message, MessageType.Error);
            }
            else
            {
                string message = string.Format(k_CacheInfoFormat, HumanizeWeight(currentCache));
                EditorGUILayout.HelpBox(message, MessageType.Info);
            }
            EditorGUILayout.PropertyField(serialized.pointCookieSize, k_PointCoockieSizeContent);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.cubeCookieTexArraySize, k_PointCookieTextureArraySizeContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.cubeCookieTexArraySize.intValue = Mathf.Clamp(serialized.cubeCookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
            }
            currentCache = TextureCacheCubemap.GetApproxCacheSizeInByte(serialized.cubeCookieTexArraySize.intValue, serialized.pointCookieSize.intValue, 1);
            if (currentCache > LightLoop.k_MaxCacheSize)
            {
                int    reserved = TextureCacheCubemap.GetMaxCacheSizeForWeightInByte(LightLoop.k_MaxCacheSize, serialized.pointCookieSize.intValue, 1);
                string message  = string.Format(k_CacheErrorFormat, HumanizeWeight(currentCache), reserved);
                EditorGUILayout.HelpBox(message, MessageType.Error);
            }
            else
            {
                string message = string.Format(k_CacheInfoFormat, HumanizeWeight(currentCache));
                EditorGUILayout.HelpBox(message, MessageType.Info);
            }
        }
        public void ReleaseResources()
        {
            if (m_AreaCookieTexArray != null)
            {
                m_AreaCookieTexArray.Release();
                m_AreaCookieTexArray = null;
            }

            CoreUtils.Destroy(m_MaterialFilterAreaLights);
            if (m_TempRenderTexture0 != null)
            {
                m_TempRenderTexture0.Release();
                m_TempRenderTexture0 = null;
            }
            if (m_TempRenderTexture1 != null)
            {
                m_TempRenderTexture1.Release();
                m_TempRenderTexture1 = null;
            }
        }
        public PlanarReflectionProbeCache(HDRenderPipelineAsset hdAsset, IBLFilterGGX iblFilter, int cacheSize, int probeSize, TextureFormat probeFormat, bool isMipmaped)
        {
            m_ConvertTextureMaterial = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.shaders.blitCubeTextureFacePS);
            m_ConvertTextureMPB      = new MaterialPropertyBlock();

            // BC6H requires CPP feature not yet available
            probeFormat = TextureFormat.RGBAHalf;

            Debug.Assert(probeFormat == TextureFormat.BC6H || probeFormat == TextureFormat.RGBAHalf, "Reflection Probe Cache format for HDRP can only be BC6H or FP16.");

            m_ProbeSize    = probeSize;
            m_CacheSize    = cacheSize;
            m_TextureCache = new TextureCache2D("PlanarReflectionProbe");
            m_TextureCache.AllocTextureArray(cacheSize, probeSize, probeSize, probeFormat, isMipmaped);
            m_IBLFilterGGX = iblFilter;

            m_PerformBC6HCompression = probeFormat == TextureFormat.BC6H;

            InitializeProbeBakingStates();
        }
        public LTCAreaLightCookieManager(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources, int maxCacheSize)
        {
            // Keep track of the render pipeline asset
            m_RenderPipelineAsset = hdAsset;

            // Create the texture cookie cache that we shall be using for the area lights
            GlobalLightLoopSettings gLightLoopSettings = hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings;

            m_AreaCookieTexArray = new TextureCache2D("AreaCookie");
            int cookieSize       = gLightLoopSettings.cookieTexArraySize;
            int cookieResolution = (int)gLightLoopSettings.cookieSize;

            if (TextureCache2D.GetApproxCacheSizeInByte(cookieSize, cookieResolution, 1) > maxCacheSize)
            {
                cookieSize = TextureCache2D.GetMaxCacheSizeForWeightInByte(maxCacheSize, cookieResolution, 1);
            }
            m_AreaCookieTexArray.AllocTextureArray(cookieSize, cookieResolution, cookieResolution, TextureFormat.RGBA32, true);

            // Also make sure to create the engine material that is used for the filtering
            m_MaterialFilterAreaLights = CoreUtils.CreateEngineMaterial(defaultResources.shaders.filterAreaLightCookiesPS);
        }
Example #10
0
        public void Release()
        {
            if (m_TextureCache != null)
            {
                m_TextureCache.Release();
                m_TextureCache = null;
            }
            if (m_TempRenderTexture != null)
            {
                m_TempRenderTexture.Release();
                m_TempRenderTexture = null;
            }
            if (m_ConvolutionTargetTexture != null)
            {
                m_ConvolutionTargetTexture.Release();
                m_ConvolutionTargetTexture = null;
            }
            m_ProbeBakingState = null;

            CoreUtils.Destroy(m_ConvertTextureMaterial);
        }
 internal static int GetMaxCacheSizeForWeightInByte(int weight, int resolution, int sliceSize)
 {
     return(TextureCache2D.GetMaxCacheSizeForWeightInByte(weight, resolution, sliceSize));
 }
 internal static long GetApproxCacheSizeInByte(int nbElement, int resolution, int sliceSize)
 {
     return(TextureCache2D.GetApproxCacheSizeInByte(nbElement, resolution, sliceSize));
 }