Graphics Reference
In-Depth Information
9. This completes our HLSL source code changes. Within our C# project, make a
copy of the DyanamicCubeMap.cs file from the previous recipe, Implementing
multithreaded cubic environment mapping , and name it DualParaboloidMap.cs .
10. Add the PerEnvMap structure and the DualMapView property to the new class.
public struct PerEnvMap
{
public Matrix View;
public float NearClip;
public float FarClip;
Vector2 _padding0;
}
public PerEnvMap DualMapView;
11. Within the DualParaboloidMap.CreateDeviceDependentResources method,
change the texture creation so that it has an array size of 2 and is not a texture cube.
var textureDesc = new Texture2DDescription()
{
...
ArraySize = 2, // 2-paraboloids
OptionFlags = ResourceOptionFlags.GenerateMipMaps,
...
};
EnvMap = ToDispose(new Texture2D(device, textureDesc));
12. Next, we need to change the Shader Resource View (SRV) declaration to use a
dimension of Texture2DArray .
// Create the SRV for the texture cube
var descSRV = new ShaderResourceViewDescription();
descSRV.Format = textureDesc.Format;
descSRV.Dimension = SharpDX.Direct3D
.ShaderResourceViewDimension.Texture2DArray;
descSRV.Texture2DArray.MostDetailedMip = 0;
descSRV.Texture2DArray.MipLevels = -1;
descSRV.Texture2DArray.FirstArraySlice = 0;
descSRV.Texture2DArray.ArraySize = 2;
13. The creation of the Render Target View (RTV) needs to use a descRTV.
Texture2DArray.ArraySize instance with a value of two instead of six.
14. The texture resource for the depth stencil will be a regular texture array with an array
size of two.
using (var depth = new Texture2D(device, new Texture2DDescription
{
...
 
Search WWH ::




Custom Search