protected override void OnDrawToSwapchainImage(VKImage image) { base.OnDrawToSwapchainImage(image); CommandBuffer[image].Submit(true); MeshRenderer.Draw(image, Tick); ParticleRenderer.Draw(image, Tick); TextRenderer.Draw(image, Tick); }
protected override void DrawSelf(SpriteBatch spriteBatch) { ParticleSystem.Draw(spriteBatch); }
public override void Draw(Squared.Render.Frame frame) { CreateRenderTargets(); LightmapMaterials.ViewportScale = new Vector2(1f / LightmapScale); LightmapMaterials.ProjectionMatrix = Matrix.CreateOrthographicOffCenter( 0, BackgroundLightmap.Width, BackgroundLightmap.Height, 0, 0, 1 ); using (var backgroundGroup = BatchGroup.ForRenderTarget(frame, 0, Background)) { ClearBatch.AddNew(backgroundGroup, 1, Game.ScreenMaterials.Clear, clearColor: Color.Transparent); using (var bb = BitmapBatch.New(backgroundGroup, 2, Game.ScreenMaterials.WorldSpaceBitmap)) { for (var i = 0; i < 1; i++) { var layer = Layers[i]; var dc = new BitmapDrawCall(layer, Vector2.Zero); dc.SortKey = i; bb.Add(dc); } } } using (var foregroundGroup = BatchGroup.ForRenderTarget(frame, 1, Foreground)) { ClearBatch.AddNew(foregroundGroup, 1, Game.ScreenMaterials.Clear, clearColor: Color.Transparent); using (var bb = BitmapBatch.New(foregroundGroup, 2, Game.ScreenMaterials.WorldSpaceBitmap)) { for (var i = 1; i < Layers.Length; i++) { var layer = Layers[i]; var dc = new BitmapDrawCall(layer, Vector2.Zero); dc.SortKey = i; bb.Add(dc); } } } using (var backgroundLightGroup = BatchGroup.ForRenderTarget(frame, 4, BackgroundLightmap)) { ClearBatch.AddNew(backgroundLightGroup, 1, LightmapMaterials.Clear, clearColor: new Color(32, 32, 32, 255), clearZ: 0, clearStencil: 0); BackgroundRenderer.RenderLighting(frame, backgroundLightGroup, 2); } using (var foregroundLightGroup = BatchGroup.ForRenderTarget(frame, 5, ForegroundLightmap)) { ClearBatch.AddNew(foregroundLightGroup, 1, LightmapMaterials.Clear, clearColor: new Color(96, 96, 96, 255), clearZ: 0, clearStencil: 0); ForegroundRenderer.RenderLighting(frame, foregroundLightGroup, 2); } SetRenderTargetBatch.AddNew(frame, 49, null); ClearBatch.AddNew(frame, 50, Game.ScreenMaterials.Clear, clearColor: Color.Black, clearZ: 0, clearStencil: 0); if (ShowLightmap) { using (var bb = BitmapBatch.New(frame, 55, Game.ScreenMaterials.WorldSpaceBitmap)) { var dc = new BitmapDrawCall(BackgroundLightmap, Vector2.Zero, LightmapScale); bb.Add(dc); } ParticleRenderer.Draw(frame, 56); } else { var dc = new BitmapDrawCall(Background, Vector2.Zero); var material = LightmapMaterials.Get(LightmapMaterials.WorldSpaceLightmappedBitmap, blendState: BlendState.AlphaBlend); using (var bb = BitmapBatch.New(frame, 55, material)) { dc.Textures = new TextureSet(Background, BackgroundLightmap); dc.SortKey = 0; bb.Add(dc); } ParticleRenderer.Draw(frame, 56); using (var bb = BitmapBatch.New(frame, 57, material)) { dc.Textures = new TextureSet(Foreground, ForegroundLightmap); dc.SortKey = 1; bb.Add(dc); } } if (ShowOutlines || (Dragging != null)) { BackgroundRenderer.RenderOutlines(frame, 59, true); } }
public override void Draw(Squared.Render.Frame frame) { CreateRenderTargets(); LightmapMaterials.ViewportScale = new Vector2(1f / LightmapScale); LightmapMaterials.ProjectionMatrix = Matrix.CreateOrthographicOffCenter( 0, BackgroundLightmap.Width, BackgroundLightmap.Height, 0, 0, 1 ); using (var backgroundGroup = BatchGroup.ForRenderTarget(frame, 0, Background)) { ClearBatch.AddNew(backgroundGroup, 1, Game.ScreenMaterials.Clear, clearColor: Color.Transparent); using (var bb = BitmapBatch.New(backgroundGroup, 2, Game.ScreenMaterials.WorldSpaceBitmap)) { for (var i = 0; i < 1; i++) { var layer = Layers[i]; var dc = new BitmapDrawCall(layer, Vector2.Zero); dc.SortKey = i; bb.Add(dc); } } } using (var foregroundGroup = BatchGroup.ForRenderTarget(frame, 1, Foreground)) { ClearBatch.AddNew(foregroundGroup, 1, Game.ScreenMaterials.Clear, clearColor: Color.Transparent); using (var bb = BitmapBatch.New(foregroundGroup, 2, Game.ScreenMaterials.WorldSpaceBitmap)) { for (var i = 1; i < Layers.Length; i++) { var layer = Layers[i]; var dc = new BitmapDrawCall(layer, Vector2.Zero); dc.SortKey = i; bb.Add(dc); } } } if (ShowBrickSpecular) { using (var bricksLightGroup = BatchGroup.ForRenderTarget(frame, 2, ForegroundLightmap)) { ClearBatch.AddNew(bricksLightGroup, 1, LightmapMaterials.Clear, clearColor: new Color(0, 0, 0, 255), clearZ: 0, clearStencil: 0); ForegroundRenderer.RenderLighting(frame, bricksLightGroup, 2); } } if (ShowAOShadow) { using (var aoShadowFirstPassGroup = BatchGroup.ForRenderTarget(frame, 3, AOShadowScratch)) { ClearBatch.AddNew(aoShadowFirstPassGroup, 1, LightmapMaterials.Clear, clearColor: Color.Transparent); using (var bb = BitmapBatch.New(aoShadowFirstPassGroup, 2, Game.ScreenMaterials.ScreenSpaceHorizontalGaussianBlur5Tap)) { bb.Add(new BitmapDrawCall(Foreground, Vector2.Zero, 1f / LightmapScale)); } } } using (var backgroundLightGroup = BatchGroup.ForRenderTarget(frame, 4, BackgroundLightmap)) { ClearBatch.AddNew(backgroundLightGroup, 1, LightmapMaterials.Clear, clearColor: new Color(40, 40, 40, 255), clearZ: 0, clearStencil: 0); BackgroundRenderer.RenderLighting(frame, backgroundLightGroup, 2); if (ShowBrickSpecular) { using (var foregroundLightBatch = BitmapBatch.New(backgroundLightGroup, 3, MaskedForegroundMaterial)) { var dc = new BitmapDrawCall( ForegroundLightmap, Vector2.Zero ); dc.Textures = new TextureSet(dc.Textures.Texture1, BricksLightMask); foregroundLightBatch.Add(dc); } } else { ForegroundRenderer.RenderLighting(frame, backgroundLightGroup, 3); } if (ShowAOShadow) { using (var aoShadowBatch = BitmapBatch.New(backgroundLightGroup, 4, AOShadowMaterial)) { var dc = new BitmapDrawCall( AOShadowScratch, new Vector2(0, 4) ); dc.MultiplyColor = Color.Black; dc.AddColor = Color.White; aoShadowBatch.Add(dc); } } } using (var foregroundLightGroup = BatchGroup.ForRenderTarget(frame, 5, ForegroundLightmap)) { ClearBatch.AddNew(foregroundLightGroup, 1, LightmapMaterials.Clear, clearColor: new Color(127, 127, 127, 255), clearZ: 0, clearStencil: 0); ForegroundRenderer.RenderLighting(frame, foregroundLightGroup, 2); } SetRenderTargetBatch.AddNew(frame, 49, null); ClearBatch.AddNew(frame, 50, Game.ScreenMaterials.Clear, clearColor: Color.Black, clearZ: 0, clearStencil: 0); if (ShowLightmap) { using (var bb = BitmapBatch.New(frame, 55, Game.ScreenMaterials.WorldSpaceBitmap)) { var dc = new BitmapDrawCall(BackgroundLightmap, Vector2.Zero, LightmapScale); bb.Add(dc); } } else { var dc = new BitmapDrawCall(Background, Vector2.Zero); var material = LightmapMaterials.Get(LightmapMaterials.WorldSpaceLightmappedBitmap, blendState: BlendState.AlphaBlend); using (var bb = BitmapBatch.New(frame, 55, material)) { dc.Textures = new TextureSet(Background, BackgroundLightmap); dc.SortKey = 0; bb.Add(dc); } ParticleRenderer.Draw(frame, 56); using (var bb = BitmapBatch.New(frame, 57, material)) { dc.Textures = new TextureSet(Foreground, ForegroundLightmap); dc.SortKey = 1; bb.Add(dc); } } if (ShowOutlines || (Dragging != null)) { BackgroundRenderer.RenderOutlines(frame, 59, true); } }