/// <summary> /// Attach vertex buffer routine /// </summary> /// <param name="context"></param> /// <param name="vertStartSlot"></param> protected override bool OnAttachBuffers(DeviceContextProxy context, ref int vertStartSlot) { bool succ = GeometryBuffer.AttachBuffers(context, this.VertexLayout, ref vertStartSlot, EffectTechnique.EffectsManager); InstanceBuffer?.AttachBuffer(context, ref vertStartSlot); return(succ); }
/// <summary> /// Called when [render]. /// </summary> /// <param name="context">The context.</param> /// <param name="deviceContext">The device context.</param> protected override void OnRender(IRenderContext context, DeviceContextProxy deviceContext) { perFrameCB.UploadDataToBuffer(deviceContext, ref FrameVariables); // Clear binding updatePass.GetShader(ShaderStage.Compute).BindUAV(deviceContext, currentStateSlot, null); updatePass.GetShader(ShaderStage.Compute).BindUAV(deviceContext, newStateSlot, null); OnTextureChanged(); OnBlendStateChanged(); // Render existing particles renderPass.BindShader(deviceContext); renderPass.BindStates(deviceContext, StateType.RasterState | StateType.DepthStencilState); renderPass.GetShader(ShaderStage.Vertex).BindTexture(deviceContext, renderStateSlot, BufferProxies[0].SRV); renderPass.GetShader(ShaderStage.Pixel).BindTexture(deviceContext, textureSlot, textureView); renderPass.GetShader(ShaderStage.Pixel).BindSampler(deviceContext, samplerSlot, textureSampler); deviceContext.DeviceContext.InputAssembler.InputLayout = VertexLayout; deviceContext.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList; int firstSlot = 0; InstanceBuffer?.AttachBuffer(deviceContext, ref firstSlot); deviceContext.DeviceContext.OutputMerger.SetBlendState(blendState, null, 0xFFFFFFFF); deviceContext.DeviceContext.DrawInstancedIndirect(particleCountGSIABuffer.Buffer, 0); InvalidateRenderer();//Since particle is running all the time. Invalidate once finished rendering }
/// <summary> /// Attach vertex buffer routine /// </summary> /// <param name="context"></param> /// <param name="vertStartSlot"></param> protected virtual bool OnAttachBuffers(DeviceContextProxy context, ref int vertStartSlot) { if (GeometryBuffer.AttachBuffers(context, ref vertStartSlot, EffectTechnique.EffectsManager)) { InstanceBuffer.AttachBuffer(context, ref vertStartSlot); return(true); } else { return(false); } }
/// <summary> /// Called when [render]. /// </summary> /// <param name="context">The context.</param> /// <param name="deviceContext">The device context.</param> protected override void OnRender(RenderContext context, DeviceContextProxy deviceContext) { perFrameCB.UploadDataToBuffer(deviceContext, ref FrameVariables); // Clear binding updatePass.ComputeShader.BindUAV(deviceContext, currentStateSlot, null); updatePass.ComputeShader.BindUAV(deviceContext, newStateSlot, null); // Render existing particles renderPass.BindShader(deviceContext); renderPass.BindStates(deviceContext, StateType.RasterState | StateType.DepthStencilState); renderPass.VertexShader.BindTexture(deviceContext, renderStateSlot, BufferProxies[0]); renderPass.PixelShader.BindTexture(deviceContext, textureSlot, textureView); renderPass.PixelShader.BindSampler(deviceContext, samplerSlot, textureSampler); deviceContext.InputLayout = VertexLayout; int firstSlot = 0; InstanceBuffer?.AttachBuffer(deviceContext, ref firstSlot); deviceContext.SetBlendState(blendState, blendFactor, sampleMask); deviceContext.DrawInstancedIndirect(particleCountGSIABuffer.Buffer, 0); InvalidateRenderer();//Since particle is running all the time. Invalidate once finished rendering }
/// <summary> /// Attach vertex buffer routine /// </summary> /// <param name="context"></param> /// <param name="vertStartSlot"></param> protected override void OnAttachBuffers(DeviceContext context, ref int vertStartSlot) { GeometryBuffer.AttachBuffers(context, this.VertexLayout, ref vertStartSlot, EffectTechnique.EffectsManager); InstanceBuffer?.AttachBuffer(context, ref vertStartSlot); }