public void Update(DX11RenderContext context) { if (!shaderData.Contains(context)) { shaderData[context] = new ShaderDeviceData(context); } if (this.spmax > 0) { if (!this.FOutLayer[0].Contains(context)) { this.FOutLayer[0][context] = new DX11Layer(); this.FOutLayer[0][context].Render = this.Render; } } }
public void Render(DX11RenderContext context, DX11RenderSettings settings) { if (this.spmax == 0) { return; } if (this.BeginQuery != null) { this.BeginQuery(context); } context.CleanShaderStages(); ShaderDeviceData deviceData = this.shaderData[context]; context.Primitives.FullScreenTriangle.Bind(null); for (int i = 0; i < spmax; i++) { if (this.FEnabled[i]) { if (this.FInState.IsConnected) { context.RenderStateStack.Push(this.FInState[i]); } else { this.defaultState.Blend = DX11BlendStates.GetState(this.FInBlendState[i]); context.RenderStateStack.Push(this.defaultState); } if (this.FInSamplerState.IsConnected) { SamplerState state = SamplerState.FromDescription(context.Device, this.FInSamplerState[i]); deviceData.samplerVariable.SetSamplerState(0, state); } else { deviceData.samplerVariable.UndoSetSamplerState(0); } var color = this.FInColor[i]; color.Alpha *= settings.LayerOpacity; deviceData.colorVariable.Set(color); deviceData.texTransformVariable.SetMatrix(this.FInTexTransform[i]); if (this.FInTexture.IsConnected) { if (this.FInTexture[i].Contains(context) && this.FInTexture[i][context] != null) { deviceData.inputTextureVariable.SetResource(this.FInTexture[i][context].SRV); } else { deviceData.inputTextureVariable.SetResource(null); } } else { deviceData.inputTextureVariable.SetResource(context.DefaultTextures.WhiteTexture.SRV); } deviceData.pass.Apply(context.CurrentDeviceContext); context.CurrentDeviceContext.Draw(3, 0); context.RenderStateStack.Pop(); } } if (this.EndQuery != null) { this.EndQuery(context); } }