public void Render(CommandList cl, IDistortionStageModel stage, GpuSurface target, ICameraModel2D camera) { cl.SetPipeline(_pipeline); cl.SetFramebuffer(target.Framebuffer); cl.ClearColorTarget(0, RgbaFloat.Clear); // HERE DIFFERENT TO STANDARD DRAW ONLY (FUTURE PULL OUT TO BASE?) cl.SetVertexBuffer(0, stage.Buffers.VertexBuffer); cl.SetIndexBuffer(stage.Buffers.IndexBuffer, IndexFormat.UInt32); //Extract format and type cl.SetGraphicsResourceSet(0, camera.ResourceSet); var batcher = stage.Batcher; for (var b = 0; b < batcher.NumberOfBatches; b++) { var batch = batcher.Pool[b]; ResourceSet t0; if (batch.Texture0 == 0UL) { t0 = _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap; } else { var retrieved = _surfaceManager.RetrieveSurface(batch.Texture0, new GpuSurfaceType[] { GpuSurfaceType.SwapChainOutput, GpuSurfaceType.Internal }); if (retrieved == target) { _frameworkMessenger.Report("Warning: A distortion stage is attempting to draw a surface onto itself. Aborting"); return; } t0 = retrieved == null ? _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap : batch.TextureMode0 == TextureCoordinateMode.Mirror ? retrieved.ResourceSet_TexMirror : retrieved.ResourceSet_TexWrap; } cl.SetGraphicsResourceSet(1, t0); ResourceSet t1; if (batch.Texture1 == 0UL) { t1 = _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap; } else { var retrieved = _surfaceManager.RetrieveSurface(batch.Texture1, new GpuSurfaceType[] { GpuSurfaceType.SwapChainOutput, GpuSurfaceType.Internal }); if (retrieved == target) { _frameworkMessenger.Report("Warning: A distortion stage is attempting to draw a surface onto itself. Aborting"); return; } t1 = retrieved == null ? _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap : batch.TextureMode1 == TextureCoordinateMode.Mirror ? retrieved.ResourceSet_TexMirror : retrieved.ResourceSet_TexWrap; } cl.SetGraphicsResourceSet(2, t1); cl.DrawIndexed((uint)batch.NumIndices, 1, (uint)batch.StartIndex, 0, 0); } }
public void DispatchToRenderStage(IDistortionStageModel stage, CommandList cl, RenderCommandQueueItem command) { stage.Process(); var surface = _surfaceManager.RetrieveSurface(command.Surface, new GpuSurfaceType[] { GpuSurfaceType.Texture, GpuSurfaceType.Internal }); var source = _surfaceManager.RetrieveSurface(command.Texture0, new GpuSurfaceType[] { GpuSurfaceType.SwapChainOutput, GpuSurfaceType.Internal }); var camera = _cameraManager.RetrieveCameraModel2D(command.Camera); _distortionEffectStageRenderer.Render(cl, stage, source, surface, camera); }
public void Render(CommandList cl, IDistortionStageModel stage, GpuSurface source, GpuSurface target) { cl.SetPipeline(_pipeline); cl.SetFramebuffer(target.Framebuffer); cl.SetVertexBuffer(0, _ndcQuadVertexBuffer.Buffer); cl.SetGraphicsResourceSet(0, stage.InternalSurfacePixelShiftUniform); cl.SetGraphicsResourceSet(1, source.ResourceSet_TexWrap); cl.ClearColorTarget(0, RgbaFloat.Clear); cl.Draw(6); }
public void Render(CommandList cl, IDistortionStageModel stage, GpuSurface source, GpuSurface target, ICameraModel2D camera) { if (cl == null || stage == null || source == null || target == null || camera == null) { _frameworkMessenger.Report("Warning: you are feeding the Distortion Stage Renderer null inputs, aborting"); return; } _heightRenderer.Render(cl, stage, stage.HeightMapSurface, camera); _gradientShiftRenderer.Render(cl, stage, stage.HeightMapSurface, stage.GradientShiftSurface); _distortionRenderer.Render(cl, stage, source, stage.GradientShiftSurface, target); }
public void Render(CommandList cl, IDistortionStageModel stage, GpuSurface source, GpuSurface shift, GpuSurface target) { float aspect = (1.0f * target.Framebuffer.Width) / (1.0f * target.Framebuffer.Height); float amount = stage.DistortionScalar / (1.0f * target.Framebuffer.Height); var distortionFactor = new DistortionFactorUniform { DistortionScalar = amount * new Vector2(aspect, 1.0f), Pad2 = Vector2.Zero, Pad3 = Vector4.Zero }; cl.SetPipeline(_pipeline); cl.UpdateBuffer(_distortionFactorBuffer, 0, ref distortionFactor); cl.SetGraphicsResourceSet(0, _distortionFactorUniformResourceSet); cl.SetFramebuffer(target.Framebuffer); _viewportManager.ConfigureViewportForActiveFramebuffer(cl); cl.SetVertexBuffer(0, _ndcQuadVertexBuffer.Buffer); cl.SetGraphicsResourceSet(1, shift.ResourceSet_TexWrap); cl.SetGraphicsResourceSet(2, source.ResourceSet_TexWrap); cl.Draw(6); }
public void CacheStageModel(IDistortionStageModel model) => CachedDistortionEffectStageModel = model;