Does your shader input match the stream? Maybe your shader expects normal data or something.
vertex shader inputs:
//--------------------------------------------------------------------------------------
// This shader computes standard transform and lighting
//--------------------------------------------------------------------------------------
VS_OUTPUT RenderSceneVS( float4 vPos : POSITION,
float3 vNormal : NORMAL,
float2 vTexCoord0 : TEXCOORD0,
uniform int nNumLights)
{
VS_OUTPUT Output;
float3 vNormalWorldSpace;
Output.Position = mul(vPos, g_mWorldViewProjection); // Transform the position from object space to homogeneous projection space
vNormalWorldSpace = normalize(mul(vNormal, (float3x3)g_mWorld)); // Transform the normal from object space to world space // normal (world space)
float3 vTotalLightDiffuse = float3(0,0,0); // Compute simple directional lighting equation
for(int i=0; i<nNumLights; i++ )
vTotalLightDiffuse += g_LightDiffuse * max(0,dot(vNormalWorldSpace, g_LightDir));
Output.Diffuse.rgb = g_MaterialDiffuseColor * vTotalLightDiffuse + g_MaterialAmbientColor * g_LightAmbient;
Output.Diffuse.a = 1.0f;
Output.TextureUV = vTexCoord0; // Just copy the texture coordinate through
return Output;
}
vertex format declaration:
D3DVERTEXELEMENT9 vertex_format[] =
{
' stream 0, offset 0, float3, no tesselation, position, usage index 0
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
' stream 0, offset 0, float3, no tesselation, normal, usage index 0
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
' stream 0, offset 0, float2, no tesselation, tex coords, usage index 0
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END()
};
the corresponding FVF for fixed function:
// const DWORD ZFVF=(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0) );
and the code to set the format:
' ---------------------------------------- create and set vertex declaration ----------------------------------------------------------
cr result Zd3d_device_ptr->CreateVertexDeclaration vertex_format &vertex_declaration
!= result D3D_OK
c msg3 "create vertex declaration error"
ret
.
c Zd3d_device_ptr->SetVertexDeclaration vertex_declaration
tried swizzling normal and texture positions in the VB, no apparent effect. OTOH, almost all values are -1, 0 , or 1.
I'm still guessing its a texture sampler stage setting that's not correct. I'm about to go over that list of switches now...
so far i have:
//--------------------------------------------------------------------------------------
// Texture samplers
//--------------------------------------------------------------------------------------
sampler MeshTextureSampler =
sampler_state
{
Texture = <g_MeshTexture>;
MinFilter = Anisotropic;
MagFilter = LINEAR;
MipFilter = LINEAR;
MaxAnisotropy = 8;
// MipFilter = LINEAR; // NONE | LINEAR
// MinFilter = LINEAR; // LINEAR | ANISOTROPIC
// MagFilter = LINEAR; // LINEAR | ANISOTROPIC
AddressU = WRAP;
AddressV = WRAP;
};