Ejemplo n.º 1
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            MyObjectBuilder_EnvironmentDefinition objBuilder = (MyObjectBuilder_EnvironmentDefinition)builder;

            FogProperties       = objBuilder.FogProperties;
            SunProperties       = objBuilder.SunProperties;
            PostProcessSettings = objBuilder.PostProcessSettings;
            SSAOSettings        = objBuilder.SSAOSettings;
            HBAOSettings        = objBuilder.HBAOSettings;
            ShadowSettings.CopyFrom(objBuilder.ShadowSettings);
            NewPipelineSettings.CopyFrom(objBuilder.NewPipelineSettings);
            MaterialsSettings.CopyFrom(objBuilder.MaterialsSettings);
            SmallShipMaxSpeed         = objBuilder.SmallShipMaxSpeed;
            LargeShipMaxSpeed         = objBuilder.LargeShipMaxSpeed;
            SmallShipMaxAngularSpeed  = objBuilder.SmallShipMaxAngularSpeed;
            LargeShipMaxAngularSpeed  = objBuilder.LargeShipMaxAngularSpeed;
            ContourHighlightColor     = new Color(objBuilder.ContourHighlightColor);
            ContourHighlightThickness = objBuilder.ContourHighlightThickness;
            HighlightPulseInSeconds   = objBuilder.HighlightPulseInSeconds;
            EnvironmentTexture        = objBuilder.EnvironmentTexture;
            EnvironmentOrientation    = objBuilder.EnvironmentOrientation;
            EnvironmentalParticles    = objBuilder.EnvironmentalParticles;
        }
Ejemplo n.º 2
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            MyObjectBuilder_EnvironmentDefinition definition = (MyObjectBuilder_EnvironmentDefinition)builder;

            this.FogProperties       = definition.FogProperties;
            this.PlanetProperties    = definition.PlanetProperties;
            this.SunProperties       = definition.SunProperties;
            this.PostProcessSettings = definition.PostProcessSettings;
            this.SSAOSettings        = definition.SSAOSettings;
            this.HBAOSettings        = definition.HBAOSettings;
            this.ShadowSettings.CopyFrom(definition.ShadowSettings);
            this.LowLoddingSettings.CopyFrom(definition.LowLoddingSettings);
            this.MediumLoddingSettings.CopyFrom(definition.MediumLoddingSettings);
            this.HighLoddingSettings.CopyFrom(definition.HighLoddingSettings);
            this.ExtremeLoddingSettings.CopyFrom(definition.ExtremeLoddingSettings);
            this.SmallShipMaxSpeed         = definition.SmallShipMaxSpeed;
            this.LargeShipMaxSpeed         = definition.LargeShipMaxSpeed;
            this.SmallShipMaxAngularSpeed  = definition.SmallShipMaxAngularSpeed;
            this.LargeShipMaxAngularSpeed  = definition.LargeShipMaxAngularSpeed;
            this.ContourHighlightColor     = new Color(definition.ContourHighlightColor);
            this.ContourHighlightThickness = definition.ContourHighlightThickness;
            this.HighlightPulseInSeconds   = definition.HighlightPulseInSeconds;
            this.EnvironmentTexture        = definition.EnvironmentTexture;
            this.EnvironmentOrientation    = definition.EnvironmentOrientation;
            this.EnvironmentalParticles    = definition.EnvironmentalParticles;
        }
Ejemplo n.º 3
0
        public static void InitEnvironmentSettings(MyObjectBuilder_EnvironmentSettings environmentBuilder = null)
        {
            if (environmentBuilder != null)
            {
                EnvironmentDefinition = MyDefinitionManager.Static.GetDefinition <MyEnvironmentDefinition>(environmentBuilder.EnvironmentDefinition);
            }
            else if (EnvironmentDefinition == null)
            {
                // Fallback
                EnvironmentDefinition = MyDefinitionManager.Static.GetDefinition <MyEnvironmentDefinition>(MyStringHash.GetOrCompute("Default"));
            }

            var environment = EnvironmentDefinition;

            SunProperties = environment.SunProperties;
            FogProperties = environment.FogProperties;
            SSAOSettings  = environment.SSAOSettings;
            HBAOSettings  = environment.HBAOSettings;
            ShadowSettings.CopyFrom(environment.ShadowSettings);
            NewPipelineSettings.CopyFrom(environment.NewPipelineSettings);
            SunRotationAxis = SunProperties.SunRotationAxis;

            MyRenderProxy.UpdateShadowsSettings(ShadowSettings);
            MyRenderProxy.UpdateNewPipelineSettings(NewPipelineSettings);
            MySector.Lodding.UpdatePreset(environment.UserLoddingSettings, environment.LowLoddingSettings, environment.MediumLoddingSettings, environment.HighLoddingSettings);

            MyMaterialsSettings materialsSettings = new MyMaterialsSettings();

            materialsSettings.CopyFrom(environment.MaterialsSettings);
            MyRenderProxy.UpdateMaterialsSettings(materialsSettings);

            // TODO: Delete MyPostprocessSettingsWrapper and move to have bundled
            // settings in MySector and change all references to point here
            MyPostprocessSettingsWrapper.Settings = environment.PostProcessSettings;

            if (environmentBuilder != null)
            {
                Vector3 sunDirection;
                Vector3.CreateFromAzimuthAndElevation(environmentBuilder.SunAzimuth, environmentBuilder.SunElevation, out sunDirection);
                sunDirection.Normalize();

                SunProperties.BaseSunDirectionNormalized = sunDirection;
                SunProperties.SunDirectionNormalized     = sunDirection;
                //SunProperties.SunIntensity = environmentBuilder.SunIntensity;

                FogProperties.FogMultiplier = environmentBuilder.FogMultiplier;
                FogProperties.FogDensity    = environmentBuilder.FogDensity;
                FogProperties.FogColor      = new Color(environmentBuilder.FogColor);
            }
        }
Ejemplo n.º 4
0
        internal static void CompilePS()
        {
            if (m_coarseAOPS == PixelShaderId.NULL || m_lastParams.BackgroundAOEnable != Params.BackgroundAOEnable ||
                m_lastParams.ForegroundAOEnable != Params.ForegroundAOEnable ||
                m_lastParams.DepthThresholdEnable != Params.DepthThresholdEnable)
            {
                m_macros.Clear();
                m_macros.Add(new SharpDX.Direct3D.ShaderMacro("FETCH_GBUFFER_NORMAL", 1));
                if (Params.BackgroundAOEnable)
                {
                    m_macros.Add(new SharpDX.Direct3D.ShaderMacro("ENABLE_BACKGROUND_AO", 1));
                }
                if (Params.ForegroundAOEnable)
                {
                    m_macros.Add(new SharpDX.Direct3D.ShaderMacro("ENABLE_FOREGROUND_AO", 1));
                }
                if (Params.DepthThresholdEnable)
                {
                    m_macros.Add(new SharpDX.Direct3D.ShaderMacro("ENABLE_DEPTH_THRESHOLD", 1));
                }
                m_coarseAOPS = MyShaders.CreatePs("Postprocess/HBAO/CoarseAO.hlsl", m_macros.ToArray());
            }

            if (m_blurXPS == PixelShaderId.NULL || m_blurYPS == PixelShaderId.NULL ||
                m_lastParams.BlurSharpnessFunctionEnable != Params.BlurSharpnessFunctionEnable ||
                m_lastParams.BlurRadius4 != Params.BlurRadius4)
            {
                m_macros.Clear();
                if (Params.BlurSharpnessFunctionEnable)
                {
                    m_macros.Add(new SharpDX.Direct3D.ShaderMacro("ENABLE_SHARPNESS_PROFILE", 1));
                }
                if (Params.BlurRadius4)
                {
                    m_macros.Add(new SharpDX.Direct3D.ShaderMacro("KERNEL_RADIUS", 4));
                }
                else
                {
                    m_macros.Add(new SharpDX.Direct3D.ShaderMacro("KERNEL_RADIUS", 2));
                }
                m_blurXPS = MyShaders.CreatePs("Postprocess/HBAO/BlurX.hlsl", m_macros.ToArray());
                m_blurYPS = MyShaders.CreatePs("Postprocess/HBAO/BlurY.hlsl", m_macros.ToArray());
            }
            m_lastParams = Params;
        }
Ejemplo n.º 5
0
 static MyHBAO()
 {
     Params = MyHBAOData.Default;
 }