Graphics Reference
In-Depth Information
The following diagram outlines the process within the pipeline:
Direct3D pipeline view of cube map generation with geometry shader instancing
To calculate the reflection in our pixel shader, we use the intrinsic HLSL reflect
function; this takes the camera direction and surface normal to compute a reflection
vector. This reflection vector is used to sample the cube from its SRV as shown in the
following diagram:
Sampling texture cube using reflection vector (right-handed coordinate system)
The view/projections are calculated for each face by taking the object's center point and
creating "look at" view matrices for all the six faces. Because we are using a right-handed
coordinate system, it is necessary for us to flip the x axis of the cube map view matrix by scaling
the x axis by -1 and reversing the vertex winding order in the geometry shader. By implementing
multithreaded deferred contexts, we can improve the performance when there is an increased
CPU load or larger numbers of draw calls (for example, more reflective surfaces).
 
Search WWH ::




Custom Search