/// <summary>
        /// Loads the game content
        /// </summary>
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // Hides the mouse
            IsMouseVisible = false;

            // Set fog values
            GraphicsDevice.Parameters.Set(FogEffectKeys.fogNearPlaneZ, 100f);
            GraphicsDevice.Parameters.Set(FogEffectKeys.fogFarPlaneZ, 160f);

            // Create the Atmosphere lighting
            Atmosphere = AtmosphereBuilder.Generate(GraphicsDevice, EffectSystem);
            CreateSunLight();

            // Lights
            EnviromentLight1 = CreateDirectLight(new Vector3(-1, -1, -1), new Color3(1, 1, 1), .3f);
            EnviromentLight2 = CreateDirectLight(new Vector3(1, 1, 1), new Color3(1, 1, 1), .3f);

            // Create the pipeline
            CreatePipeline();
            CreateCursor();

            // Entities
            LoadTerrain();
            LoadCamera();

            // Scripts
            Script.Add(MovementScript);
            Script.Add(RenderChunksScript);
            Script.Add(BuildTerrain);
            Script.Add(LightCycleScript);
        }
Beispiel #2
0
        public AtmosphereBuilder(GraphicsDevice device, EffectSystem effectSystem)
        {
            blendState = BlendState.New(device, new BlendStateDescription(Blend.One, Blend.One)).DisposeBy(this);

            Data = new AtmosphereData(device, new AtmosphereSettings());

            // TODO: Use max precision temporary textures

            /*
             *          var intermediateTransmittanceDesc = Data.Transmittance.Description;
             *          intermediateTransmittanceDesc.Format = PixelFormat.R32G32B32A32_Float;
             *          var intermediateIrradianceDesc = Data.Irradiance.Description;
             *          intermediateIrradianceDesc.Format = PixelFormat.R32G32B32A32_Float;
             *          var intermediateInscatterDesc = Data.Inscatter.Description;
             *          intermediateInscatterDesc.Format = PixelFormat.R32G32B32A32_Float;
             *
             *          var intermediateTransmittance = Texture2D.New(device, intermediateTransmittanceDesc).DisposeBy(this);
             *          var intermediateIrradiance = Texture3D.New(device, intermediateIrradianceDesc).DisposeBy(this);
             *          var intermediateInscatter = Texture3D.New(device, intermediateInscatterDesc).DisposeBy(this);
             */

            deltaE  = Texture.New(device, Data.Irradiance.Description).DisposeBy(this);
            deltaSM = Texture.New(device, Data.Inscatter.Description).DisposeBy(this);
            deltaSR = Texture.New(device, Data.Inscatter.Description).DisposeBy(this);
            deltaJ  = Texture.New(device, Data.Inscatter.Description).DisposeBy(this);

            computeTransmittance      = effectSystem.LoadEffect("ComputeTransmittance");
            computeSingleIrradiance   = effectSystem.LoadEffect("SingleIrradiance");
            copySingleInscatter       = effectSystem.LoadEffect("CopySingleInscatter");
            computeSingleInscatter    = effectSystem.LoadEffect("SingleInscatter");
            computeOutscatter         = effectSystem.LoadEffect("Outscatter");
            computeMultipleIrradiance = effectSystem.LoadEffect("MultipleIrradiance");
            computeMultipleInscatter  = effectSystem.LoadEffect("MultipleInscatter");
            copyMultipleInscatter     = effectSystem.LoadEffect("CopyMultipleInscatter");
            copySlice = effectSystem.LoadEffect("CopySlice");

            parameters.Set(AtmospherePrecomputationKeys.DeltaSR, deltaSR);
            parameters.Set(AtmospherePrecomputationKeys.DeltaSM, deltaSM);
            parameters.Set(AtmospherePrecomputationKeys.DeltaE, deltaE);
            parameters.Set(AtmospherePrecomputationKeys.DeltaJ, deltaJ);
        }
Beispiel #3
0
        public static AtmosphereData Generate(GraphicsDevice device, EffectSystem effectSystem)
        {
            if (VirtualFileSystem.ApplicationCache.FileExists("atmosphere"))
            {
                using (var stream = VirtualFileSystem.ApplicationCache.OpenStream("atmosphere", VirtualFileMode.Open, VirtualFileAccess.Read))
                {
                    return(AtmosphereData.Load(device, stream));
                }
            }
            else
            {
                using (var builder = new AtmosphereBuilder(device, effectSystem))
                {
                    builder.Generate(device);

                    using (var stream = VirtualFileSystem.ApplicationCache.OpenStream("atmosphere", VirtualFileMode.Create, VirtualFileAccess.Write))
                    {
                        builder.Data.Save(stream);
                    }

                    return(builder.Data);
                }
            }
        }
Beispiel #4
0
 public AtmosphereRenderer(IServiceRegistry services, AtmosphereData data, LightComponent sunLight)
     : base(services)
 {
     this.data     = data;
     this.sunLight = sunLight;
 }