Graphics Reference
In-Depth Information
17. After that, we will define the Render Target View (RTV) for our texture cube.
// Create the RTVs
var descRTV = new RenderTargetViewDescription();
descRTV.Format = textureDesc.Format;
descRTV.Dimension = RenderTargetViewDimension
.Texture2DArray;
descRTV.Texture2DArray.MipSlice = 0;
// Single RTV array for single pass rendering
descRTV.Texture2DArray.FirstArraySlice = 0;
descRTV.Texture2DArray.ArraySize = 6;
EnvMapRTV = ToDispose(new RenderTargetView(device, EnvMap,
descRTV));
18. And then, we will create the Depth Stencil View (DSV) for rendering our cube map.
// Create DSVs
using (var depth = new Texture2D(device, new Texture2DDescription
{ Format = Format.D32_Float,
BindFlags = BindFlags.DepthStencil,
Height = Size,
Width = Size,
Usage = ResourceUsage.Default,
SampleDescription = new SampleDescription(1, 0),
CpuAccessFlags = CpuAccessFlags.None,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.TextureCube,
ArraySize = 6 // 6-sides of the cube
}))
{ var descDSV = new DepthStencilViewDescription();
descDSV.Format = depth.Description.Format;
descDSV.Dimension = DepthStencilViewDimension
.Texture2DArray;
descDSV.Flags = DepthStencilViewFlags.None;
descDSV.Texture2DArray.MipSlice = 0;
// Single DSV array for single pass rendering
descDSV.Texture2DArray.FirstArraySlice = 0;
descDSV.Texture2DArray.ArraySize = 6;
EnvMapDSV = ToDispose(new DepthStencilView(device,
depth, descDSV));
}
19. Lastly, we will create the viewport and per environment map buffer.
// Create the viewport
Viewport = new Viewport(0, 0, Size, Size);
 
Search WWH ::




Custom Search