private void RenderTextured(DX11RenderContext context, DX11RenderSettings settings) { QuadShaderDeviceData qd = quaddata[context]; qd.quadshader.SelectTechnique("RenderTextured"); qd.quadgeometry.Bind(qd.quadlayouts[1]); for (int i = 0; i < this.spmax; i++) { bool popstate = false; if (this.FInState.IsConnected) { context.RenderStateStack.Push(this.FInState[i]); popstate = true; } if (this.FInSamplerState.IsConnected) { SamplerState state = SamplerState.FromDescription(context.Device, this.FInSamplerState[i]); qd.samplervariable.SetSamplerState(0, state); } else { qd.samplervariable.UndoSetSamplerState(0); } qd.quadshader.SetBySemantic("COLOR", this.FInColor[i]); qd.quadshader.SetBySemantic("WORLD", this.FInWorld[i]); qd.quadshader.SetBySemantic("TEXTUREMATRIX", this.FInTexTransform[i]); if (this.FInTexture[i].Contains(context) && this.FInTexture[i][context] != null) { qd.texturevariable.SetResource(this.FInTexture[i][context].SRV); } else { qd.texturevariable.SetResource(null); } qd.quadshader.ApplyPass(0); if (settings.DepthOnly) { context.CurrentDeviceContext.PixelShader.Set(null); } qd.quadgeometry.Draw(); if (popstate) { context.RenderStateStack.Pop(); } } }
private void RenderInstancedTextured(DX11RenderContext context, DX11RenderSettings settings) { QuadShaderDeviceData qd = quaddata[context]; bool popstate = false; if (this.FInState.IsConnected) { context.RenderStateStack.Push(this.FInState[0]); popstate = true; } if (this.FInSamplerState.IsConnected) { SamplerState state = SamplerState.FromDescription(context.Device, this.FInSamplerState[0]); qd.samplervariable.SetSamplerState(0, state); } else { qd.samplervariable.UndoSetSamplerState(0); } qd.quadshader.SelectTechnique("RenderInstancedTextured"); qd.quadgeometry.Bind(qd.quadlayouts[3]); qd.quadshader.SetBySemantic("LAYEROPACITY", settings.LayerOpacity); this.BindBuffers(context); if (this.FInTexture[0].Contains(context) && this.FInTexture[0][context] != null) { qd.texturevariable.SetResource(this.FInTexture[0][context].SRV); } else { qd.texturevariable.SetResource(null); } qd.quadshader.ApplyPass(0); if (settings.DepthOnly) { context.CurrentDeviceContext.PixelShader.Set(null); } context.CurrentDeviceContext.DrawIndexedInstanced(qd.quadgeometry.IndexBuffer.IndicesCount, this.spmax, 0, 0, 0); if (popstate) { context.RenderStateStack.Pop(); } }
public void Render(IPluginIO pin, DX11RenderContext context, DX11RenderSettings settings) { if (this.spmax > 0) { if (this.FEnabled[0]) { context.CleanShaderStages(); QuadShaderDeviceData qd = quaddata[context]; qd.quadshader.SetBySemantic("VIEWPROJECTION", settings.ViewProjection); if (this.BeginQuery != null) { this.BeginQuery(context); } bool multisampler = this.FInSamplerState.SliceCount > 1 && this.FInTexture.IsConnected; if (this.FInState.SliceCount > 1 || this.FInTexture.SliceCount > 1 || multisampler) { if (this.FInTexture.IsConnected) { this.RenderTextured(context); } else { this.RenderBasic(context); } } else { if (this.FInTexture.IsConnected) { this.RenderInstancedTextured(context); } else { this.RenderInstanced(context); } } if (this.EndQuery != null) { this.EndQuery(context); } } } }
private void RenderInstancedTextured(DX11RenderContext context) { QuadShaderDeviceData qd = quaddata[context]; bool popstate = false; if (this.FInState.IsConnected) { context.RenderStateStack.Push(this.FInState[0]); popstate = true; } if (this.FInSamplerState.PluginIO.IsConnected) { SamplerState state = SamplerState.FromDescription(context.Device, this.FInSamplerState[0]); qd.samplervariable.SetSamplerState(0, state); } else { qd.samplervariable.UndoSetSamplerState(0); } qd.quadshader.SelectTechnique("RenderInstancedTextured"); qd.quadgeometry.Bind(qd.quadlayouts[3]); this.BindBuffers(context); if (this.FInTexture[0].Contains(context)) { qd.texturevariable.SetResource(this.FInTexture[0][context].SRV); } else { qd.texturevariable.SetResource(null); } qd.quadshader.ApplyPass(0); context.CurrentDeviceContext.DrawIndexedInstanced(qd.quadgeometry.IndexBuffer.IndicesCount, this.spmax, 0, 0, 0); if (popstate) { context.RenderStateStack.Pop(); } }
private void RenderBasic(DX11RenderContext context, DX11RenderSettings settings) { QuadShaderDeviceData qd = quaddata[context]; qd.quadshader.SelectTechnique("Render"); qd.quadgeometry.Bind(qd.quadlayouts[0]); for (int i = 0; i < this.spmax; i++) { bool popstate = false; if (this.FInState.IsConnected) { context.RenderStateStack.Push(this.FInState[i]); popstate = true; } var color = this.FInColor[i]; color.Alpha *= settings.LayerOpacity; qd.quadshader.SetBySemantic("COLOR", color); qd.quadshader.SetBySemantic("WORLD", this.FInWorld[i]); qd.quadshader.SetBySemantic("TEXTUREMATRIX", this.FInTexTransform[i]); qd.quadshader.ApplyPass(0); if (settings.DepthOnly) { context.CurrentDeviceContext.PixelShader.Set(null); } qd.quadgeometry.Draw(); if (popstate) { context.RenderStateStack.Pop(); } } }
public void Update(IPluginIO pin, DX11RenderContext context) { lock( syncRoot) { if (!quaddata.ContainsKey(context)) { quaddata[context] = new QuadShaderDeviceData(context); } if (!quadBuffers.ContainsKey(context)) { quadBuffers[context] = new QuadBuffers(); } } if (this.spmax > 0) { if (!this.FOutLayer[0].Contains(context)) { this.FOutLayer[0][context] = new DX11Layer(); this.FOutLayer[0][context].Render = this.Render; } } }