public override void Rebuild()
        {
            ClearComputeBuffers();

            s_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
            s_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture");

            s_punctualLightList = new ComputeBuffer(MaxLights, System.Runtime.InteropServices.Marshal.SizeOf(typeof(PunctualLightData)));
            s_envLightList      = new ComputeBuffer(MaxLights, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData)));

            m_DeferredMaterial  = CreateEngineMaterial("Hidden/Unity/LightingDeferred");
            m_FinalPassMaterial = CreateEngineMaterial("Hidden/Unity/FinalPass");

            // Debug
            m_DebugViewMaterialGBuffer = CreateEngineMaterial("Hidden/Unity/DebugViewMaterialGBuffer");

            // m_ShadowPass = new ShadowRenderPass (m_ShadowSettings);

            m_cubeReflTexArray = new TextureCacheCubemap();
            m_cubeReflTexArray.AllocTextureArray(32, (int)m_TextureSettings.reflectionCubemapSize, TextureFormat.BC6H, true);

            // Init Lit material buffer - GBuffer and init
            m_LitRenderLoop = new Lit.RenderLoop(); // Our object can be garbacge collected, so need to be allocate here

            m_gbufferManager.gbufferCount = m_LitRenderLoop.GetGBufferCount();
            for (int gbufferIndex = 0; gbufferIndex < m_gbufferManager.gbufferCount; ++gbufferIndex)
            {
                m_gbufferManager.SetBufferDescription(gbufferIndex, "_CameraGBufferTexture" + gbufferIndex, m_LitRenderLoop.RTFormat[gbufferIndex], m_LitRenderLoop.RTReadWrite[gbufferIndex]);
            }

            m_LitRenderLoop.Rebuild();
        }
Пример #2
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);
         }
     }
 }
 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;
 }
        public ReflectionProbeCache(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 TextureCacheCubemap();
            m_TextureCache.AllocTextureArray(cacheSize, 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);
            }
        }
Пример #7
0
        public ReflectionProbeCache(HDRenderPipelineAsset hdAsset, IBLFilterGGX iblFilter, int cacheSize, int probeSize, TextureFormat probeFormat, bool isMipmaped)
        {
            m_ConvertTextureMaterial = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.shaders.blitCubeTextureFacePS);
            m_ConvertTextureMPB      = new MaterialPropertyBlock();
            m_CubeToPano             = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.shaders.cubeToPanoPS);

            // 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 TextureCacheCubemap("ReflectionProbe");
            m_TextureCache.AllocTextureArray(cacheSize, probeSize, probeFormat, isMipmaped, m_CubeToPano);
            m_IBLFilterGGX = iblFilter;

            m_PerformBC6HCompression = probeFormat == TextureFormat.BC6H;

            InitializeProbeBakingStates();
        }
        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);
            CoreUtils.Destroy(m_CubeToPano);
        }
Пример #9
0
 internal static int GetMaxCacheSizeForWeightInByte(int weight, int resolution)
 {
     return(TextureCacheCubemap.GetMaxCacheSizeForWeightInByte(weight, resolution));
 }
Пример #10
0
 internal static long GetApproxCacheSizeInByte(int nbElement, int resolution)
 {
     return(TextureCacheCubemap.GetApproxCacheSizeInByte(nbElement, resolution));
 }