Graphics Reference
In-Depth Information
10. Within the ParticleRenderer.CreateDeviceDependentResources method,
first override and reset the device resources using RemoveAndDispose , and then
compile the vertex and pixel shaders VSMain and PSMain respectively.
11. Next, we will create the two blend states, as shown in the following code:
#region Blend States
var blendDesc = new BlendStateDescription() {
IndependentBlendEnable = false,
AlphaToCoverageEnable = false,
};
// Additive blend state that darkens when overlapped
blendDesc.RenderTarget[0] = new RenderTargetBlendDescription
{
IsBlendEnabled = true,
BlendOperation = BlendOperation.Add,
AlphaBlendOperation = BlendOperation.Add,
SourceBlend = BlendOption.SourceAlpha,
DestinationBlend = BlendOption.InverseSourceAlpha ,
SourceAlphaBlend = BlendOption.One,
DestinationAlphaBlend = BlendOption.Zero,
RenderTargetWriteMask = ColorWriteMaskFlags.All
};
blendState = ToDispose(new BlendState(device, blendDesc));
// Additive blend state that lightens when overlapped
// (needs a dark background)
blendDesc.RenderTarget[0]
. DestinationBlend = BlendOption.One ;
blendStateLight = ToDispose(new BlendState(device,
blendDesc));
#endregion
12. Next, we will create our depth stencil state that disables the write operation.
// depth stencil state to disable Z-buffer write
disableDepthWrite = ToDispose(new DepthStencilState(device,
new DepthStencilStateDescription {
DepthComparison = Comparison.Less,
DepthWriteMask = SharpDX.Direct3D11.DepthWriteMask.Zero,
IsDepthEnabled = true,
IsStencilEnabled = false
}));
 
Search WWH ::




Custom Search