public PostProcessor(Device device, ShaderCache shaderCache, Size2 size) { ResultTexture = new Texture2D(device, new Texture2DDescription() { Format = ColorFormat, Width = size.Width, Height = size.Height, ArraySize = 1, SampleDescription = new SampleDescription(1, 0), MipLevels = 1, Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource }); ResultTargetView = new RenderTargetView(device, ResultTexture); ResultSourceView = new ShaderResourceView(device, ResultTexture); constantsBuffer = new ConstantBufferManager <PostProcessorConstants>(device); StateDescriptions postProcessingStateDesc = StateDescriptions.Common.Clone(); postProcessingStateDesc.rasterizer.CullMode = CullMode.None; postProcessingStates = new States(device, postProcessingStateDesc); fullScreenVertexShader = shaderCache.GetVertexShader <RenderPassController>("game/rendering/FullScreenVertexShader"); postProcessingShader = shaderCache.GetPixelShader <RenderPassController>("game/rendering/postprocess/PostProcessingShader"); }
public RenderPassController(Device device, ShaderCache shaderCache, Size2 targetSize) { this.viewport = new Viewport( 0, 0, targetSize.Width, targetSize.Height, 0.0f, 1.0f); standardTarget = new StandardTarget(device, targetSize); oitBlendTarget = new OitBlendTarget(device, shaderCache, targetSize); postProcessor = new PostProcessor(device, shaderCache, targetSize); StateDescriptions opaquePassStateDesc = StateDescriptions.Common.Clone(); opaquePassStateDesc.rasterizer.IsMultisampleEnabled = true; opaquePassStateDesc.rasterizer.CullMode = CullMode.Back; this.oneSidedOpaquePassStates = new States(device, opaquePassStateDesc); opaquePassStateDesc.rasterizer.CullMode = CullMode.None; this.twoSidedOpaquePassStates = new States(device, opaquePassStateDesc); StateDescriptions backToFrontTransparencyPassStateDesc = StateDescriptions.Common.Clone(); backToFrontTransparencyPassStateDesc.rasterizer.IsMultisampleEnabled = true; backToFrontTransparencyPassStateDesc.depthStencil.DepthWriteMask = DepthWriteMask.Zero; backToFrontTransparencyPassStateDesc.blend.RenderTarget[0].IsBlendEnabled = true; backToFrontTransparencyPassStateDesc.blend.RenderTarget[0].SourceBlend = BlendOption.One; backToFrontTransparencyPassStateDesc.blend.RenderTarget[0].DestinationBlend = BlendOption.InverseSourceAlpha; backToFrontTransparencyPassStateDesc.rasterizer.CullMode = CullMode.Front; this.backToFrontTransparencyBackFacesPassStates = new States(device, backToFrontTransparencyPassStateDesc); backToFrontTransparencyPassStateDesc.rasterizer.CullMode = CullMode.Back; this.backToFrontTransparencyFrontFacesPassStates = new States(device, backToFrontTransparencyPassStateDesc); backToFrontTransparencyPassStateDesc.rasterizer.CullMode = CullMode.None; this.backToFrontTransparencyAllFacesPassStates = new States(device, backToFrontTransparencyPassStateDesc); StateDescriptions unorderedTransparencyStateDesc = StateDescriptions.Common.Clone(); unorderedTransparencyStateDesc.rasterizer.IsMultisampleEnabled = false; unorderedTransparencyStateDesc.rasterizer.CullMode = CullMode.None; unorderedTransparencyStateDesc.depthStencil.DepthWriteMask = DepthWriteMask.Zero; unorderedTransparencyStateDesc.blend.IndependentBlendEnable = true; unorderedTransparencyStateDesc.blend.RenderTarget[0].IsBlendEnabled = true; unorderedTransparencyStateDesc.blend.RenderTarget[0].SourceBlend = BlendOption.One; unorderedTransparencyStateDesc.blend.RenderTarget[0].SourceAlphaBlend = BlendOption.One; unorderedTransparencyStateDesc.blend.RenderTarget[0].DestinationBlend = BlendOption.One; unorderedTransparencyStateDesc.blend.RenderTarget[0].DestinationAlphaBlend = BlendOption.One; unorderedTransparencyStateDesc.blend.RenderTarget[1].IsBlendEnabled = true; unorderedTransparencyStateDesc.blend.RenderTarget[1].SourceBlend = BlendOption.Zero; unorderedTransparencyStateDesc.blend.RenderTarget[1].SourceAlphaBlend = BlendOption.Zero; unorderedTransparencyStateDesc.blend.RenderTarget[1].DestinationBlend = BlendOption.InverseSourceAlpha; unorderedTransparencyStateDesc.blend.RenderTarget[1].DestinationAlphaBlend = BlendOption.InverseSourceAlpha; this.unorderedTransparencyPassStates = new States(device, unorderedTransparencyStateDesc); }
public FaceTransparencyProcessor(Device device, ShaderCache shaderCache, Figure figure, SurfaceProperties surfaceProperties) { this.device = device; this.figure = figure; this.surfaceProperties = surfaceProperties; faceCount = figure.Geometry.Faces.Length; faceTransparencies = new float[faceCount]; var vertexShaderAndBytecode = shaderCache.GetVertexShader <TextureMaskRenderer>("occlusion/facetransparency/TransparencyCounting"); inputLayout = new InputLayout(device, vertexShaderAndBytecode.Bytecode, MeshBuffers.InputElements); vertexShader = vertexShaderAndBytecode; addingPixelShader = shaderCache.GetPixelShader <TextureMaskRenderer>("occlusion/facetransparency/TransparencyCounting_Add"); maxingPixelShader = shaderCache.GetPixelShader <TextureMaskRenderer>("occlusion/facetransparency/TransparencyCounting_Max"); var statesDesc = StateDescriptions.Default(); statesDesc.rasterizer.CullMode = CullMode.None; states = new States(device, statesDesc); }
public OitBlendTarget(Device device, ShaderCache shaderCache, Size2 size) { AccumTexture = new Texture2D(device, new Texture2DDescription { Format = ColorFormat, Width = size.Width, Height = size.Height, ArraySize = 1, SampleDescription = new SampleDescription(1, 0), MipLevels = 1, Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource }); AccumTargetView = new RenderTargetView(device, AccumTexture); AccumResourceView = new ShaderResourceView(device, AccumTexture); RevealageTexture = new Texture2D(device, new Texture2DDescription() { Format = RevealageFormat, Width = size.Width, Height = size.Height, ArraySize = 1, SampleDescription = new SampleDescription(1, 0), MipLevels = 1, Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None }); RevealageTargetView = new RenderTargetView(device, RevealageTexture); RevealageSourceView = new ShaderResourceView(device, RevealageTexture); DepthTexture = new Texture2D(device, new Texture2DDescription { Format = DepthTextureFormat, Width = size.Width, Height = size.Height, ArraySize = 1, SampleDescription = new SampleDescription(1, 0), MipLevels = 1, Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource }); DepthTargetView = new DepthStencilView(device, DepthTexture, new DepthStencilViewDescription { Format = DepthTargetFormat, Dimension = DepthStencilViewDimension.Texture2D }); DepthSourceView = new ShaderResourceView(device, DepthTexture, new ShaderResourceViewDescription { Format = DepthResourceFormat, Dimension = ShaderResourceViewDimension.Texture2D, Texture2D = new ShaderResourceViewDescription.Texture2DResource { MipLevels = 1, MostDetailedMip = 0 } }); StateDescriptions depthCopyingStateDesc = StateDescriptions.Common.Clone(); depthCopyingStateDesc.rasterizer.CullMode = CullMode.None; depthCopyingStates = new States(device, depthCopyingStateDesc); StateDescriptions compositingStateDesc = StateDescriptions.Common.Clone(); compositingStateDesc.rasterizer.CullMode = CullMode.None; compositingStates = new States(device, compositingStateDesc); fullScreenVertexShader = shaderCache.GetVertexShader <RenderPassController>("game/rendering/FullScreenVertexShader"); depthCopyingShader = shaderCache.GetPixelShader <RenderPassController>("game/rendering/DepthCopyingShader"); compositingShader = shaderCache.GetPixelShader <RenderPassController>("game/rendering/UnorderedTransparencyCompositingShader"); }
public States(Device device, StateDescriptions description) { rasterizer = new RasterizerState(device, description.rasterizer); depthStencil = new DepthStencilState(device, description.depthStencil); blend = new BlendState(device, description.blend); }