public override void LoadContent() { LightmapMaterials = new DefaultMaterialSet(Game.Services); // Since the spiral is very detailed LightingEnvironment.DefaultSubdivision = 128f; Environment = new LightingEnvironment(); Renderer = new LightingRenderer(Game.Content, Game.RenderCoordinator, LightmapMaterials, Environment); var light = new LightSource { Position = new Vector2(64, 64), Color = new Vector4(1f, 1f, 1f, 1), RampStart = 50, RampEnd = 275, }; Lights.Add(light); Environment.LightSources.Add(light); var rng = new Random(1234); for (var i = 0; i < 25; i++) { light = new LightSource { Position = new Vector2(64, 64), Color = new Vector4((float)rng.NextDouble(0.1f, 1.0f), (float)rng.NextDouble(0.1f, 1.0f), (float)rng.NextDouble(0.1f, 1.0f), 1.0f), RampStart = rng.NextFloat(24, 40), RampEnd = rng.NextFloat(140, 160), RampMode = LightSourceRampMode.Exponential }; Lights.Add(light); Environment.LightSources.Add(light); } const int spiralCount = 1800; float spiralRadius = 0, spiralRadiusStep = 330f / spiralCount; float spiralAngle = 0, spiralAngleStep = (float)(Math.PI / (spiralCount / 36f)); Vector2 previous = default(Vector2); for (int i = 0; i < spiralCount; i++, spiralAngle += spiralAngleStep, spiralRadius += spiralRadiusStep) { var current = new Vector2( (float)(Math.Cos(spiralAngle) * spiralRadius) + (Width / 2f), (float)(Math.Sin(spiralAngle) * spiralRadius) + (Height / 2f) ); if (i > 0) { Environment.Obstructions.Add(new LightObstructionLine( previous, current )); } previous = current; } }
public override void LoadContent () { LightmapMaterials = new DefaultMaterialSet(Game.Services); // Since the spiral is very detailed LightingEnvironment.DefaultSubdivision = 128f; Environment = new LightingEnvironment(); Renderer = new LightingRenderer(Game.Content, Game.RenderCoordinator, LightmapMaterials, Environment); var light = new LightSource { Position = new Vector2(64, 64), Color = new Vector4(1f, 1f, 1f, 1), RampStart = 50, RampEnd = 275, }; Lights.Add(light); Environment.LightSources.Add(light); var rng = new Random(1234); for (var i = 0; i < 25; i++) { light = new LightSource { Position = new Vector2(64, 64), Color = new Vector4((float)rng.NextDouble(0.1f, 1.0f), (float)rng.NextDouble(0.1f, 1.0f), (float)rng.NextDouble(0.1f, 1.0f), 1.0f), RampStart = rng.NextFloat(24, 40), RampEnd = rng.NextFloat(140, 160), RampMode = LightSourceRampMode.Exponential }; Lights.Add(light); Environment.LightSources.Add(light); } const int spiralCount = 1800; float spiralRadius = 0, spiralRadiusStep = 330f / spiralCount; float spiralAngle = 0, spiralAngleStep = (float)(Math.PI / (spiralCount / 36f)); Vector2 previous = default(Vector2); for (int i = 0; i < spiralCount; i++, spiralAngle += spiralAngleStep, spiralRadius += spiralRadiusStep) { var current = new Vector2( (float)(Math.Cos(spiralAngle) * spiralRadius) + (Width / 2f), (float)(Math.Sin(spiralAngle) * spiralRadius) + (Height / 2f) ); if (i > 0) { Environment.Obstructions.Add(new LightObstructionLine( previous, current )); } previous = current; } }
public override void LoadContent() { LightmapMaterials = new DefaultMaterialSet(Game.Services); Environment = new LightingEnvironment(); TestImage = Game.Content.Load <Texture2D>("ramp_test_image"); RampTexture = Game.Content.Load <Texture2D>("LightGradients"); Environment.LightSources.AddRange(new[] { new LightSource { Position = new Vector2(128, 128), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Linear }, new LightSource { Position = new Vector2(400, 128), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Exponential }, new LightSource { Position = new Vector2(128, 400), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Linear, RampTexture = RampTexture }, new LightSource { Position = new Vector2(400, 400), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Exponential, RampTexture = RampTexture } }); Renderer = new LightingRenderer(Game.Content, Game.RenderCoordinator, LightmapMaterials, Environment); }
private void LightingRenderer_Render(On.Celeste.LightingRenderer.orig_Render orig, LightingRenderer self, Scene scene) { if (Settings.SimplifiedGraphics) { return; } orig(self, scene); }
public override void LoadContent() { LightmapMaterials = new DefaultMaterialSet(Game.Services); LightingEnvironment.DefaultSubdivision = 512f; BackgroundEnvironment = new LightingEnvironment(); ForegroundEnvironment = new LightingEnvironment(); BackgroundRenderer = new LightingRenderer(Game.Content, LightmapMaterials, BackgroundEnvironment); ForegroundRenderer = new LightingRenderer(Game.Content, LightmapMaterials, ForegroundEnvironment); // Add a global sun AddAmbientLight(746, -300); // Add clipped suns for areas with weird shadowing behavior AddAmbientLight(746, 200, new Bounds( new Vector2(38, 33), new Vector2(678, 678) )); AddAmbientLight(740, 240, new Bounds( new Vector2(805, 34), new Vector2(1257, 546) )); AddAmbientLight(741, 750, new Bounds( new Vector2(0, 674), new Vector2(1257, 941) )); AddAmbientLight(741, 1025, new Bounds( new Vector2(0, 941), new Vector2(1257, 1250) )); AddTorch(102, 132); AddTorch(869, 132); AddTorch(102, 646); AddTorch(869, 645); GenerateObstructionsFromTiles(); Layers[0] = Game.Content.Load<Texture2D>("layers_bg"); Layers[1] = Game.Content.Load<Texture2D>("layers_fg"); Layers[2] = Game.Content.Load<Texture2D>("layers_chars"); Layers[3] = Game.Content.Load<Texture2D>("layers_torches"); BricksLightMask = Game.Content.Load<Texture2D>("layers_bricks_lightmask"); AdditiveBitmapMaterial = LightmapMaterials.ScreenSpaceBitmap.SetStates(blendState: BlendState.Additive); MaskedForegroundMaterial = LightmapMaterials.ScreenSpaceLightmappedBitmap.SetStates(blendState: BlendState.Additive); AOShadowMaterial = Game.ScreenMaterials.ScreenSpaceVerticalGaussianBlur5Tap.SetStates(blendState: RenderStates.SubtractiveBlend); ParticleRenderer = new ParticleRenderer(LightmapMaterials) { Viewport = new Bounds(Vector2.Zero, new Vector2(Width, Height)) }; Spark.Texture = Game.Content.Load<Texture2D>("spark"); ParticleRenderer.Systems = new[] { Sparks = new ParticleSystem<Spark>( new DotNetTimeProvider(), BackgroundEnvironment ) }; }
private static void onLightingBeforeRender(On.Celeste.LightingRenderer.orig_BeforeRender orig, LightingRenderer self, Scene scene) { orig(self, scene); Draw.SpriteBatch.GraphicsDevice.SetRenderTarget(GameplayBuffers.Light); Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.Identity); foreach (Entity entity in scene.Entities) { if (entity is Strawberry berry) { DynData <Strawberry> berryData = new DynData <Strawberry>(berry); if (berryData.Get <bool>("SpringCollab2020_ignoreLighting")) { Draw.SpriteBatch.Draw(strawberryCutoutTexture.Texture.Texture, berry.Position + berryData.Get <Sprite>("sprite").Position - (scene as Level).Camera.Position - new Vector2(9, 8), Color.White); } } } Draw.SpriteBatch.End(); }
public override void LoadContent() { LightmapMaterials = new DefaultMaterialSet(Game.Services); Environment = new LightingEnvironment(); TestImage = Game.Content.Load<Texture2D>("ramp_test_image"); RampTexture = Game.Content.Load<Texture2D>("LightGradients"); Environment.LightSources.AddRange(new[] { new LightSource { Position = new Vector2(128, 128), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Linear }, new LightSource { Position = new Vector2(400, 128), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Exponential }, new LightSource { Position = new Vector2(128, 400), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Linear, RampTexture = RampTexture }, new LightSource { Position = new Vector2(400, 400), Color = Vector4.One, RampStart = 32, RampEnd = 128, RampMode = LightSourceRampMode.Exponential, RampTexture = RampTexture } }); Renderer = new LightingRenderer(Game.Content, LightmapMaterials, Environment); }
private static void LightingRendererOnRender(On.Celeste.LightingRenderer.orig_BeforeRender orig, LightingRenderer self, Scene scene) { CenterTheCamera(() => orig(self, scene)); }
public override void LoadContent() { LightmapMaterials = new DefaultMaterialSet(Game.Services); LightingEnvironment.DefaultSubdivision = 512f; BackgroundEnvironment = new LightingEnvironment(); ForegroundEnvironment = new LightingEnvironment(); BackgroundRenderer = new LightingRenderer(Game.Content, Game.RenderCoordinator, LightmapMaterials, BackgroundEnvironment); ForegroundRenderer = new LightingRenderer(Game.Content, Game.RenderCoordinator, LightmapMaterials, ForegroundEnvironment); // Add a global sun AddAmbientLight(746, -300); // Add clipped suns for areas with weird shadowing behavior AddAmbientLight(746, 200, new Bounds( new Vector2(38, 33), new Vector2(678, 678) )); AddAmbientLight(740, 240, new Bounds( new Vector2(805, 34), new Vector2(1257, 546) )); AddAmbientLight(741, 750, new Bounds( new Vector2(0, 674), new Vector2(1257, 941) )); AddAmbientLight(741, 1025, new Bounds( new Vector2(0, 941), new Vector2(1257, 1250) )); GenerateObstructionsFromTiles(); Layers[0] = Game.Content.Load <Texture2D>("layers_bg"); Layers[1] = Game.Content.Load <Texture2D>("layers_fg"); Layers[2] = Game.Content.Load <Texture2D>("layers_chars"); Layers[3] = Game.Content.Load <Texture2D>("layers_torches"); MaskedForegroundMaterial = LightmapMaterials.ScreenSpaceLightmappedBitmap.SetStates(blendState: BlendState.Additive); ParticleRenderer = new ParticleRenderer(LightmapMaterials) { Viewport = new Bounds(Vector2.Zero, new Vector2(Width, Height)) }; Spark.Texture = Game.Content.Load <Texture2D>("spark"); ParticleRenderer.Systems = new[] { Sparks = new ParticleSystem <Spark>( new DotNetTimeProvider(), BackgroundEnvironment ) }; SparkLights = new ParticleLightManager <Spark>( Sparks, new[] { BackgroundEnvironment, ForegroundEnvironment }, UpdateSectorLight ); }
private void onLightingRender(On.Celeste.LightingRenderer.orig_BeforeRender orig, LightingRenderer self, Scene scene) { float origSpotlightAlpha = 0f; Player player = scene?.Tracker.GetEntity <Player>(); PlayerDeadBody deadPlayer = null; if (player == null) { deadPlayer = scene?.Entities?.OfType <PlayerDeadBody>().FirstOrDefault(); } if (Settings.DisableMadelineSpotlight) { // save the lighting alpha, then replace it. if (player != null) { origSpotlightAlpha = player.Light.Alpha; player.Light.Alpha = 0f; } else if (deadPlayer != null) { VertexLight light = new DynData <PlayerDeadBody>(deadPlayer).Get <VertexLight>("light"); origSpotlightAlpha = light.Alpha; light.Alpha = 0f; } } orig(self, scene); if (Settings.DisableMadelineSpotlight) { // restore the spotlight if (player != null) { player.Light.Alpha = origSpotlightAlpha; } else if (deadPlayer != null) { VertexLight light = new DynData <PlayerDeadBody>(deadPlayer).Get <VertexLight>("light"); light.Alpha = origSpotlightAlpha; } } }
private static void onLightingBeforeRender(On.Celeste.LightingRenderer.orig_BeforeRender orig, LightingRenderer self, Scene scene) { orig(self, scene); Draw.SpriteBatch.GraphicsDevice.SetRenderTarget(GameplayBuffers.Light); Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.Identity); foreach (MultiRoomStrawberrySeed seed in scene.Tracker.GetEntities <MultiRoomStrawberrySeed>()) { if (seed.cutoutTexture != null) { Draw.SpriteBatch.Draw(seed.cutoutTexture.Texture.Texture, seed.Position + seed.spriteObject.Position - (scene as Level).Camera.Position - new Vector2(seed.cutoutTexture.Width / 2, seed.cutoutTexture.Height / 2), Color.White); } } Draw.SpriteBatch.End(); }
private static void LightHook(On.Celeste.LightingRenderer.orig_BeforeRender orig, LightingRenderer self, Scene scene) { if (alphaFade < 1f) { // multiply all alphas by alphaFade, and back up original values. List <VertexLight> affectedVertexLights = new List <VertexLight>(); List <float> originalAlpha = new List <float>(); foreach (VertexLight vertexLight in scene.Tracker.GetComponents <VertexLight>().ToArray()) { if (vertexLight.Visible && !vertexLight.Spotlight) { affectedVertexLights.Add(vertexLight); originalAlpha.Add(vertexLight.Alpha); vertexLight.Alpha *= alphaFade; } } // render the lighting. orig(self, scene); // restore original alphas. int index = 0; foreach (VertexLight vertexLight in affectedVertexLights) { vertexLight.Alpha = originalAlpha[index++]; } } else { // alpha multiplier is 1: nothing to modify, go on with vanilla. orig(self, scene); } }