Graphics Reference
In-Depth Information
// Render the scene using the view, projection, RTV and DSV
// Note that we use an identity matrix for the projection!
renderScene(context,
this.DualMapView.View,
Matrix.Identity
, EnvMapRTV, EnvMapDSV, this);
// Unbind the RTV and DSV
context.OutputMerger.ResetTargets();
// Prepare the SRV mip levels
context.GenerateMips(EnvMapSRV);
...
}
This completes the changes to the
DualParaboloidMap
class.
19. Within
MeshRenderer.cs
, change the type for the
EnvironmentMap
property.
public
DualParaboloidMap
EnvironmentMap { get; set; }
20. In the
MeshRenderer.DoRender
method, where the
IsReflective
property of
the material constant buffer is prepared, make the following highlighted changes:
...SNIP
if (this.EnvironmentMap != null)
{
material.IsReflective = 1;
material.ReflectionAmount = 0.4f;
context.PixelShader.SetShaderResource(1,
this.EnvironmentMap.EnvMapSRV);
// Assign the per dual map buffer to the PS
// stage at slot 4
context.PixelShader.SetConstantBuffer(4,
this.EnvironmentMap.PerEnvMapBuffer);
}
...SNIP
21. Within the
D3DApp.CreateDeviceDependentResources
method, compile the
DualParaboloidMap.hlsl
shaders, namely,
VS_DualMap
,
GS_DualMap
, and
PS_DualMap
, using the
vs_5_0
,
gs_5_0
, and
ps_5_0
shader profiles respectively.
22. Next, change all of the remaining instances of
DynamicCubeMap
to
DualParaboloidMap
throughout the
D3DApp
class.
23. Our last change pertains to multithreaded rendering within the
renderScene
method, and for the thread
Task
delegate, it is necessary to assign the environment
map constant buffer to vertex and pixel shaders.
// If multithreaded
...
// If we are rendering for an env map we must set the
// per environment map constant buffer.