Graphics Reference
In-Depth Information
OptionFlags = ResourceOptionFlags.None,
ArraySize = 2 // 2-sides of the env map
}))
15. And the corresponding Depth Stencil View (DSV) is also initialized with an array
size of two .
descDSV.Texture2DArray.ArraySize = 2;
EnvMapDSV = ToDispose(new DepthStencilView(device, depth,
descDSV));
16. Lastly, the DualParaboloidMap.PerEnvMapBuffer property needs to be
initialized with the size of the PerEnvMap structure.
PerEnvMapBuffer = ToDispose(new Buffer(device,
Utilities.SizeOf<PerEnvMap>(), ResourceUsage.Default,
BindFlags.ConstantBuffer, CpuAccessFlags.None,
ResourceOptionFlags.None, 0));
17. The SetViewPoint method will now be changed to update the
DualParaboloidMap.DualMapView property as follows:
public void SetViewPoint(Vector3 camera)
{
this.DualMapView.View = Matrix.LookAtRH(camera, camera
+ Vector3.UnitZ Vector3.UnitY);
this.DualMapView.NearClip = 0.0f;
this.DualMapView.FarClip = 100.0f;
}
18. In order to complete the changes in the DualParaboloidMap class, we will change
the UpdateSinglePass function with the following highlighted changes:
public void UpdateSinglePass(DeviceContext context,
Action<DeviceContext, Matrix, Matrix, RenderTargetView,
DepthStencilView, DualParaboloidMap > renderScene)
{
...
context.Rasterizer.SetViewport(Viewport);
// Update perCubeMap with the ViewProjections
PerEnvMap pem = this.DualMapView;
pem.View.Transpose(); // transpose the matrix for HLSL
context.UpdateSubresource(ref pem, PerEnvMapBuffer);
// Assign the buffer to the VS and PS stages at slot 4
context.VertexShader.SetConstantBuffer(4, PerEnvMapBuffer);
context.PixelShader.SetConstantBuffer(4, PerEnvMapBuffer);
 
Search WWH ::




Custom Search