Graphics Reference
In-Depth Information
In this recipe, we will look at the changes necessary to use a right-handed coordinate
system and what this means for our 3D assets. This recipe can be applied to any
SharpDX Direct3D application.
How to do it…
We will first step through the changes to the view and projection setup and then look at the
changes necessary to the vertices within the simple QuadRenderer class.
1.
When creating the view matrix, use SharpDX.Matrix.LookAtRH instead of
SharpDX.Matrix.LookAtLH as shown in the following code:
// Create the view matrix from our camera position, look
// target and up direction
var viewMatrix = Matrix.LookAtRH (cameraPosition, cameraTarget,
cameraUp);
2.
When creating the projection matrix, use SharpDX.Matrix.PerspectiveFovRH
instead of SharpDX.Matrix.PerspectiveFovLH as shown in the following
code snippet:
var projectionMatrix = Matrix.PerspectiveFovRH (
(float)Math.PI / 3f, Width / (float)Height, 0.5f, 100f);
3.
Depending on how the 3D assets were authored and exported, it may be necessary to
create a rasterizer state that correctly reflects the vertex winding order. The following
example applies back-face culling with a clockwise vertex winding order representing
front faces:
var rasterizerState = ToDispose(new RasterizerState(device, new
RasterizerStateDescription()
{
FillMode = FillMode.Solid,
CullMode = CullMode.Back,
IsFrontCounterClockwise = false,
}));
For assets requiring a counter-clockwise winding order, a rasterizer state
with IsFrontCounterClockwise set to true can be used.
 
Search WWH ::




Custom Search