public LightStats GetLightStatsByLayer(int layer)
        {
            var returnStats = new LightStats();

            foreach (var light in visibleLights)
            {
                if (!light.IsLitLayer(layer))
                {
                    continue;
                }

                returnStats.totalLights++;
                if (light.useNormalMap)
                {
                    returnStats.totalNormalMapUsage++;
                }
                if (light.volumeOpacity > 0)
                {
                    returnStats.totalVolumetricUsage++;
                }

                returnStats.blendStylesUsed |= (uint)(1 << light.blendStyleIndex);
            }

            return(returnStats);
        }
Exemple #2
0
        public LightStats GetLightStatsByLayer(int layer)
        {
            var returnStats = new LightStats();

            foreach (var light in visibleLights)
            {
                if (!light.IsLitLayer(layer))
                {
                    continue;
                }

                returnStats.totalLights++;
                if (light.normalMapQuality != Light2D.NormalMapQuality.Disabled)
                {
                    returnStats.totalNormalMapUsage++;
                }
                if (light.volumeIntensity > 0)
                {
                    returnStats.totalVolumetricUsage++;
                }

                returnStats.blendStylesUsed |= (uint)(1 << light.blendStyleIndex);
                if (light.lightType != Light2D.LightType.Global)
                {
                    returnStats.blendStylesWithLights |= (uint)(1 << light.blendStyleIndex);
                }
            }

            return(returnStats);
        }
Exemple #3
0
        public static void RenderNormals(this IRenderPass2D pass, ScriptableRenderContext context, RenderingData renderingData, DrawingSettings drawSettings, FilteringSettings filterSettings, RenderTargetIdentifier depthTarget, CommandBuffer cmd, LightStats lightStats)
        {
            using (new ProfilingScope(cmd, m_ProfilingSampler))
            {
                // figure out the scale
                var normalRTScale = 0.0f;

                if (depthTarget != BuiltinRenderTextureType.None)
                {
                    normalRTScale = 1.0f;
                }
                else
                {
                    normalRTScale = Mathf.Clamp(pass.rendererData.lightRenderTextureScale, 0.01f, 1.0f);
                }

                pass.CreateNormalMapRenderTexture(renderingData, cmd, normalRTScale);

                if (depthTarget != BuiltinRenderTextureType.None)
                {
                    cmd.SetRenderTarget(
                        pass.rendererData.normalsRenderTarget.Identifier(),
                        RenderBufferLoadAction.DontCare,
                        RenderBufferStoreAction.Store,
                        depthTarget,
                        RenderBufferLoadAction.Load,
                        RenderBufferStoreAction.Store);
                }
                else
                {
                    cmd.SetRenderTarget(pass.rendererData.normalsRenderTarget.Identifier(), RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);
                }

                cmd.ClearRenderTarget(false, true, k_NormalClearColor);

                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                drawSettings.SetShaderPassName(0, k_NormalsRenderingPassName);
                context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref filterSettings);
            }
        }