예제 #1
0
 internal static void MigrateToRayTracing(ref FrameSettings cameraFrameSettings)
 {
     cameraFrameSettings.SetEnabled(FrameSettingsField.RayTracing, true);
 }
예제 #2
0
#pragma warning disable 618 // Type or member is obsolete
#pragma warning disable 612
        internal static void MigrateFromClassVersion(ref ObsoleteFrameSettings oldFrameSettingsFormat, ref FrameSettings newFrameSettingsFormat, ref FrameSettingsOverrideMask newFrameSettingsOverrideMask)
        {
            if (oldFrameSettingsFormat == null)
            {
                return;
            }

            // no need to migrate those computed at frame value
            //newFrameSettingsFormat.diffuseGlobalDimmer = oldFrameSettingsFormat.diffuseGlobalDimmer;
            //newFrameSettingsFormat.specularGlobalDimmer = oldFrameSettingsFormat.specularGlobalDimmer;

            // Data
            switch (oldFrameSettingsFormat.shaderLitMode)
            {
            case ObsoleteLitShaderMode.Forward:
                newFrameSettingsFormat.litShaderMode = LitShaderMode.Forward;
                break;

            case ObsoleteLitShaderMode.Deferred:
                newFrameSettingsFormat.litShaderMode = LitShaderMode.Deferred;
                break;

            default:
                throw new ArgumentException("Unknown ObsoleteLitShaderMode");
            }

            newFrameSettingsFormat.SetEnabled(FrameSettingsField.ShadowMaps, oldFrameSettingsFormat.enableShadow);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.ContactShadows, oldFrameSettingsFormat.enableContactShadows);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.Shadowmask, oldFrameSettingsFormat.enableShadowMask);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.SSR, oldFrameSettingsFormat.enableSSR);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.SSAO, oldFrameSettingsFormat.enableSSAO);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.SubsurfaceScattering, oldFrameSettingsFormat.enableSubsurfaceScattering);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.Transmission, oldFrameSettingsFormat.enableTransmission);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.AtmosphericScattering, oldFrameSettingsFormat.enableAtmosphericScattering);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.Volumetrics, oldFrameSettingsFormat.enableVolumetrics);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.ReprojectionForVolumetrics, oldFrameSettingsFormat.enableReprojectionForVolumetrics);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.LightLayers, oldFrameSettingsFormat.enableLightLayers);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.DepthPrepassWithDeferredRendering, oldFrameSettingsFormat.enableDepthPrepassWithDeferredRendering);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.TransparentPrepass, oldFrameSettingsFormat.enableTransparentPrepass);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.MotionVectors, oldFrameSettingsFormat.enableMotionVectors);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.ObjectMotionVectors, oldFrameSettingsFormat.enableObjectMotionVectors);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.Decals, oldFrameSettingsFormat.enableDecals);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.Refraction, oldFrameSettingsFormat.enableRoughRefraction);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.TransparentPostpass, oldFrameSettingsFormat.enableTransparentPostpass);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.Distortion, oldFrameSettingsFormat.enableDistortion);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.Postprocess, oldFrameSettingsFormat.enablePostprocess);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.OpaqueObjects, oldFrameSettingsFormat.enableOpaqueObjects);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.TransparentObjects, oldFrameSettingsFormat.enableTransparentObjects);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.MSAA, oldFrameSettingsFormat.enableMSAA);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.ExposureControl, oldFrameSettingsFormat.enableExposureControl);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.AsyncCompute, oldFrameSettingsFormat.enableAsyncCompute);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.LightListAsync, oldFrameSettingsFormat.runLightListAsync);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.SSRAsync, oldFrameSettingsFormat.runSSRAsync);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.SSAOAsync, oldFrameSettingsFormat.runSSAOAsync);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.ContactShadowsAsync, oldFrameSettingsFormat.runContactShadowsAsync);
            newFrameSettingsFormat.SetEnabled(FrameSettingsField.VolumeVoxelizationsAsync, oldFrameSettingsFormat.runVolumeVoxelizationAsync);

            if (oldFrameSettingsFormat.lightLoopSettings != null)
            {
                newFrameSettingsFormat.SetEnabled(FrameSettingsField.DeferredTile, oldFrameSettingsFormat.lightLoopSettings.enableDeferredTileAndCluster);
                newFrameSettingsFormat.SetEnabled(FrameSettingsField.ComputeLightEvaluation, oldFrameSettingsFormat.lightLoopSettings.enableComputeLightEvaluation);
                newFrameSettingsFormat.SetEnabled(FrameSettingsField.ComputeLightVariants, oldFrameSettingsFormat.lightLoopSettings.enableComputeLightVariants);
                newFrameSettingsFormat.SetEnabled(FrameSettingsField.ComputeMaterialVariants, oldFrameSettingsFormat.lightLoopSettings.enableComputeMaterialVariants);
                newFrameSettingsFormat.SetEnabled(FrameSettingsField.FPTLForForwardOpaque, oldFrameSettingsFormat.lightLoopSettings.enableFptlForForwardOpaque);
                newFrameSettingsFormat.SetEnabled(FrameSettingsField.BigTilePrepass, oldFrameSettingsFormat.lightLoopSettings.enableBigTilePrepass);
            }

            // OverrideMask
            newFrameSettingsOverrideMask.mask = new BitArray128();
            Array values = Enum.GetValues(typeof(ObsoleteFrameSettingsOverrides));

            foreach (ObsoleteFrameSettingsOverrides val in values)
            {
                if ((val & oldFrameSettingsFormat.overrides) > 0)
                {
                    switch (val)
                    {
                    case ObsoleteFrameSettingsOverrides.Shadow:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ShadowMaps] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.ContactShadow:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ContactShadows] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.ShadowMask:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.Shadowmask] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.SSR:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.SSR] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.SSAO:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.SSAO] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.SubsurfaceScattering:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.SubsurfaceScattering] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.Transmission:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.Transmission] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.AtmosphericScaterring:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.AtmosphericScattering] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.Volumetrics:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.Volumetrics] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.ReprojectionForVolumetrics:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ReprojectionForVolumetrics] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.LightLayers:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.LightLayers] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.ShaderLitMode:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.LitShaderMode] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.DepthPrepassWithDeferredRendering:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.DepthPrepassWithDeferredRendering] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.TransparentPrepass:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.TransparentPrepass] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.MotionVectors:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.MotionVectors] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.ObjectMotionVectors:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ObjectMotionVectors] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.Decals:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.Decals] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.RoughRefraction:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.Refraction] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.TransparentPostpass:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.TransparentPostpass] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.Distortion:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.Distortion] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.Postprocess:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.Postprocess] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.OpaqueObjects:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.OpaqueObjects] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.TransparentObjects:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.TransparentObjects] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.MSAA:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.MSAA] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.ExposureControl:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ExposureControl] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.AsyncCompute:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.AsyncCompute] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.LightListAsync:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.LightListAsync] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.SSRAsync:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.SSRAsync] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.SSAOAsync:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.SSAOAsync] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.ContactShadowsAsync:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ContactShadowsAsync] = true;
                        break;

                    case ObsoleteFrameSettingsOverrides.VolumeVoxelizationsAsync:
                        newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.VolumeVoxelizationsAsync] = true;
                        break;

                    default:
                        throw new ArgumentException("Unknown ObsoleteFrameSettingsOverride, was " + val);
                    }
                }
            }

            if (oldFrameSettingsFormat.lightLoopSettings != null)
            {
                values = Enum.GetValues(typeof(ObsoleteLightLoopSettingsOverrides));
                foreach (ObsoleteLightLoopSettingsOverrides val in values)
                {
                    if ((val & oldFrameSettingsFormat.lightLoopSettings.overrides) > 0)
                    {
                        switch (val)
                        {
                        case ObsoleteLightLoopSettingsOverrides.TileAndCluster:
                            newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.DeferredTile] = true;
                            break;

                        case ObsoleteLightLoopSettingsOverrides.BigTilePrepass:
                            newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.BigTilePrepass] = true;
                            break;

                        case ObsoleteLightLoopSettingsOverrides.ComputeLightEvaluation:
                            newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ComputeLightEvaluation] = true;
                            break;

                        case ObsoleteLightLoopSettingsOverrides.ComputeLightVariants:
                            newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ComputeLightVariants] = true;
                            break;

                        case ObsoleteLightLoopSettingsOverrides.ComputeMaterialVariants:
                            newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.ComputeMaterialVariants] = true;
                            break;

                        case ObsoleteLightLoopSettingsOverrides.FptlForForwardOpaque:
                            newFrameSettingsOverrideMask.mask[(int)FrameSettingsField.FPTLForForwardOpaque] = true;
                            break;

                        default:
                            throw new ArgumentException("Unknown ObsoleteLightLoopSettingsOverrides");
                        }
                    }
                }
            }

            //free space:
            oldFrameSettingsFormat = null;
        }
예제 #3
0
#pragma warning restore 618 // Type or member is obsolete

        internal static void MigrateToAfterPostprocess(ref FrameSettings cameraFrameSettings)
        {
            cameraFrameSettings.SetEnabled(FrameSettingsField.AfterPostprocess, true);
        }
예제 #4
0
 internal static void MigrateToNoDirectSpecularLighting(ref FrameSettings cameraFrameSettings)
 {
     cameraFrameSettings.SetEnabled(FrameSettingsField.DirectSpecularLighting, false);
 }
예제 #5
0
 internal static void MigrateRoughDistortion(ref FrameSettings cameraFrameSettings)
 {
     cameraFrameSettings.SetEnabled(FrameSettingsField.RoughDistortion, true);
 }
예제 #6
0
 internal static void MigrateToSeparateColorGradingAndTonemapping(ref FrameSettings cameraFrameSettings)
 {
     cameraFrameSettings.SetEnabled(FrameSettingsField.Tonemapping, true);
 }
예제 #7
0
#pragma warning restore 618 // Type or member is obsolete

        internal static void MigrateToCustomPostprocessAndCustomPass(ref FrameSettings cameraFrameSettings)
        {
            cameraFrameSettings.SetEnabled(FrameSettingsField.CustomPass, true);
            cameraFrameSettings.SetEnabled(FrameSettingsField.CustomPostProcess, true);
        }
예제 #8
0
        // Note: this version is the one tested as there is issue getting HDRenderPipelineAsset in batchmode in unit test framework currently.
        /// <summary>Same than FrameSettings.AggregateFrameSettings but keep history of agregation in a collection for DebugMenu.
        /// Aggregation is default with override of the renderer then sanitazed depending on supported features of hdrpasset. Then the DebugMenu override occurs.</summary>
        /// <param name="aggregatedFrameSettings">The aggregated FrameSettings result.</param>
        /// <param name="camera">The camera rendering.</param>
        /// <param name="additionalData">Additional data of the camera rendering.</param>
        /// <param name="defaultFrameSettings">Base framesettings to copy prior any override.</param>
        /// <param name="supportedFeatures">Currently supported feature for the sanitazation pass.</param>
        public static void AggregateFrameSettings(ref FrameSettings aggregatedFrameSettings, Camera camera, HDAdditionalCameraData additionalData, ref FrameSettings defaultFrameSettings, RenderPipelineSettings supportedFeatures)
        {
            FrameSettingsHistory history = new FrameSettingsHistory
            {
                camera      = camera,
                defaultType = additionalData ? additionalData.defaultFrameSettings : FrameSettingsRenderType.Camera
            };

            aggregatedFrameSettings = defaultFrameSettings;
            if (additionalData && additionalData.customRenderingSettings)
            {
                FrameSettings.Override(ref aggregatedFrameSettings, additionalData.renderingPathCustomFrameSettings, additionalData.renderingPathCustomFrameSettingsOverrideMask);
                history.customMask = additionalData.renderingPathCustomFrameSettingsOverrideMask;
            }
            history.overridden = aggregatedFrameSettings;
            FrameSettings.Sanitize(ref aggregatedFrameSettings, camera, supportedFeatures);

            bool noHistory        = !frameSettingsHistory.ContainsKey(camera);
            bool updatedComponent = !noHistory && frameSettingsHistory[camera].sanitazed != aggregatedFrameSettings;
            bool dirty            = noHistory || updatedComponent;

            history.sanitazed = aggregatedFrameSettings;
            if (dirty)
            {
                history.debug = history.sanitazed;
            }
            else
            {
                history.debug = frameSettingsHistory[camera].debug;

                // Ensure user is not trying to activate unsupported settings in DebugMenu
                FrameSettings.Sanitize(ref history.debug, camera, supportedFeatures);
            }

            aggregatedFrameSettings      = history.debug;
            frameSettingsHistory[camera] = history;
        }
예제 #9
0
        internal RenderGraphResource RenderShadows(RenderGraph renderGraph, CullingResults cullResults, FrameSettings frameSettings, string shadowPassName)
        {
            RenderGraphResource result = new RenderGraphResource();

            if (m_ShadowRequests.Count == 0)
            {
                return(result);
            }

            using (var builder = renderGraph.AddRenderPass <RenderShadowsPassData>(shadowPassName, out var passData, ProfilingSampler.Get(HDProfileId.RenderShadowMaps)))
            {
                passData.parameters = PrepareRenderShadowsParameters();
                // TODO: Get rid of this and refactor to use the same kind of API than RendererList
                passData.shadowDrawSettings = new ShadowDrawingSettings(cullResults, 0);
                passData.shadowDrawSettings.useRenderingLayerMaskTest = frameSettings.IsEnabled(FrameSettingsField.LightLayers);
                passData.atlasTexture = builder.WriteTexture(
                    renderGraph.CreateTexture(new TextureDesc(width, height)
                {
                    filterMode = m_FilterMode, depthBufferBits = m_DepthBufferBits, isShadowMap = true, name = m_Name, clearBuffer = passData.parameters.debugClearAtlas
                }, passData.parameters.atlasShaderID));

                result = passData.atlasTexture;

                if (passData.parameters.blurAlgorithm == BlurAlgorithm.EVSM)
                {
                    passData.momentAtlasTexture1 = builder.WriteTexture(AllocateMomentAtlas(renderGraph, string.Format("{0}Moment", m_Name), passData.parameters.momentAtlasShaderID));
                    passData.momentAtlasTexture2 = builder.WriteTexture(AllocateMomentAtlas(renderGraph, string.Format("{0}MomentCopy", m_Name)));

                    result = passData.momentAtlasTexture1;
                }
                else if (passData.parameters.blurAlgorithm == BlurAlgorithm.IM)
                {
                    passData.momentAtlasTexture1 = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(width, height)
                    {
                        colorFormat = GraphicsFormat.R32G32B32A32_SFloat, name = string.Format("{0}Moment", m_Name), enableRandomWrite = true
                    }, passData.parameters.momentAtlasShaderID));
                    passData.intermediateSummedAreaTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(width, height)
                    {
                        colorFormat = GraphicsFormat.R32G32B32A32_SInt, name = string.Format("{0}IntermediateSummedArea", m_Name), enableRandomWrite = true
                    }, passData.parameters.momentAtlasShaderID));
                    passData.summedAreaTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(width, height)
                    {
                        colorFormat = GraphicsFormat.R32G32B32A32_SInt, name = string.Format("{0}SummedArea", m_Name), enableRandomWrite = true
                    }, passData.parameters.momentAtlasShaderID));

                    result = passData.momentAtlasTexture1;
                }


                builder.SetRenderFunc(
                    (RenderShadowsPassData data, RenderGraphContext context) =>
                {
                    RTHandle atlasTexture = context.resources.GetTexture(data.atlasTexture);
                    RenderShadows(data.parameters,
                                  atlasTexture,
                                  data.shadowDrawSettings,
                                  context.renderContext, context.cmd);

                    if (data.parameters.blurAlgorithm == BlurAlgorithm.EVSM)
                    {
                        RTHandle[] momentTextures = context.renderGraphPool.GetTempArray <RTHandle>(2);
                        momentTextures[0]         = context.resources.GetTexture(data.momentAtlasTexture1);
                        momentTextures[1]         = context.resources.GetTexture(data.momentAtlasTexture2);

                        EVSMBlurMoments(data.parameters, atlasTexture, momentTextures, context.cmd);
                    }
                    else if (data.parameters.blurAlgorithm == BlurAlgorithm.IM)
                    {
                        RTHandle momentAtlas            = context.resources.GetTexture(data.momentAtlasTexture1);
                        RTHandle intermediateSummedArea = context.resources.GetTexture(data.intermediateSummedAreaTexture);
                        RTHandle summedArea             = context.resources.GetTexture(data.summedAreaTexture);
                        IMBlurMoment(data.parameters, atlasTexture, momentAtlas, intermediateSummedArea, summedArea, context.cmd);
                    }
                });

                return(result);
            }
        }