Graphics Reference
In-Depth Information
.SetConstantBuffer(4, PerEnvMapBuffer);
// Render scene using the view, projection, RTV and DSV
renderScene(context, Cameras[0].View,
Cameras[0].Projection, EnvMapRTV, EnvMapDSV, this);
// Unbind the RTV and DSV
context.OutputMerger.ResetTargets();
// Prepare the SRV mip levels
context.GenerateMips(EnvMapSRV);
// Re-enable the Reflector renderer
if (Reflector != null)
Reflector.Show = true;
}
This completes our DynamicCubeMap renderer class. Next, we need to update the
MeshRenderer class to consume DyanamicCubeMap.EnvMapSRV .
22. Within MeshRenderer , add a new public property for assigning a cube map.
public DynamicCubeMap EnvironmentMap { get; set; }
23. In the MeshRenderer.DoRender method, where the material constant buffer is
prepared, add the following code to assign the cube map SRV:
...SNIP
// If this mesh has a cube map assigned set
// the material buffer accordingly
if (this.EnvironmentMap != null)
{
material.IsReflective = 1;
material.ReflectionAmount = 0.4f;
context.PixelShader.SetShaderResource(1,
this.EnvironmentMap.EnvMapSRV);
}
// Update material buffer
context.UpdateSubresource(ref material, PerMaterialBuffer);
...SNIP
For our final changes, we'll move over to D3DApp.cs where we will compile
the *_CubeMap shaders, move our rendering logic into a reusable action,
and implement threading.
24. We will compile the shaders in CubeMap.hlsl within D3DApp.
CreateDeviceDependentResources as we have done in previous chapters.
Compile the shader functions VS_CubeMap , GS_CubeMap , and PS_CubeMap
using the vs_5_0 , gs_5_0 , and ps_5_0 shader profiles respectively.
 
Search WWH ::




Custom Search