Graphics Reference
In-Depth Information
ShaderSignature.GetInputSignature(vertexShaderBytecode),
new[]
{
new InputElement("SV_Position",0,Format. R32G32B32 _Float,0,0),
new InputElement( "NORMAL" , 0, Format. R32G32B32_Float, 12 , 0),
new InputElement("COLOR", 0, Format. R8G8B8A8_UNorm , 24 , 0),
}));
A float ( Format.*_Float ) and signed/unsigned normalized integer
( Format.*_SNorm / Format.*_UNorm ) format will resolve to a vector of
floating-point values within the shader, whereas a signed/unsigned integer
( Format.*_SInt / Format.*_UInt ) will resolve to a vector of integers.
The vertex position ( SV_Position ) is a special case that will always resolve
to a float4 variable within the shader, even if only three floats are specified.
The fourth float component ( Position.w ) will be automatically set to 1.0 .
The legacy vertex Position semantic is still supported and is what the
Visual Studio .DGSL file uses when producing shader code.
2. Rather than using an array of floats for our vertices, we will create struct for the
vertex structure. This makes it easier to update the vertex structure and provides us
with more flexibility. Add a new class file to the project and call it Vertex.cs . Add the
following code to this file:
using System.Runtime.InteropServices;
using SharpDX;
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Vertex
{
public Vector3 Position;
public Vector3 Normal;
public Color Color;
// Constructor taking position, normal and color
public Vertex(Vector3 position, Vector3 normal, Color color)
{
Position = position;
Normal = normal;
Color = color;
}
// Snip: additional constructors here
}
 
Search WWH ::




Custom Search