Note that there are some explanatory texts on larger screens.

plurals
  1. POThe vertex structure of a mesh vs the vertex structure of the vertex shader
    primarykey
    data
    text
    <p>[Using HLSL, an *.fx file and DirectX9]</p> <p>I'm new to using shaders and have got a scenario working but don't understand why. I'm confused as to how the mesh can have one version of the vertex decleration while the shader can define another. </p> <p>I create a <code>ID3DXMesh</code> sphere with <code>D3DXCreateSphere(...)</code>, which comes setup with <code>D3DFVF_XYZ | D3DFVF_NORMAL</code>. I call <code>ID3DXMesh::DrawSubset(0)</code> to render; inside BeginPass/EndPass calls.</p> <p>I then have a vertex shader with the struct defined:</p> <pre><code>struct Vertex { float4 position:POSITION; float2 textureCoords:TEXCOORD0; float3 lightDir:TEXCOORD1; float3 normal:TEXCOORD2; }; </code></pre> <p>and the shader itself:</p> <pre><code>Vertex vertexShader( Vertex original, float3 _normal:NORMAL ) { Vertex result = (Vertex)0; float4x4 worldViewMatrix = mul( worldMatrix, viewMatrix ); float4x4 worldViewProjectionMatrix = mul( worldViewMatrix, projectionMatrix ); result.position = mul( original.position, worldViewProjectionMatrix ); result.normal = -normalize( mul(_normal, worldMatrix) ); result.textureCoords = original.textureCoords; result.lightDir = normalize(presetLightDir); return result; } </code></pre> <p>While I recognize that the lightDir and textureCoords might as well be null before I set them, what data does DirectX actually give in that <code>Vertex original</code> parameter? </p> <p>Just the position? I notice that the <code>float3 _normal:NORMAL</code> is offered as a separate parameter but is that value also inside <code>original</code> at the start of the shader too?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload