Пример #1
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);
        }
Пример #2
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);


                var msaaEnabled = renderingData.cameraData.cameraTargetDescriptor.msaaSamples > 1;
                var storeAction = msaaEnabled ? RenderBufferStoreAction.Resolve : RenderBufferStoreAction.Store;
                if (depthTarget != BuiltinRenderTextureType.None)
                {
                    cmd.SetRenderTarget(
                        pass.rendererData.normalsRenderTarget.Identifier(),
                        RenderBufferLoadAction.DontCare,
                        storeAction,
                        depthTarget,
                        RenderBufferLoadAction.Load,
                        RenderBufferStoreAction.Store);
                }
                else
                {
                    cmd.SetRenderTarget(pass.rendererData.normalsRenderTarget.Identifier(), RenderBufferLoadAction.DontCare, storeAction);
                }

                cmd.ClearRenderTarget(false, true, k_NormalClearColor);

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

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