FrozenHeart
FrozenHeart

Reputation: 20756

D3DXCompileShader cannot compile shader with NORMAL in it

I noticed that the D3DXCompileShader function from the Ogre library fails in case of DirectX9 because of the following reason:

error X4502: invalid vs_2_0 output semantic 'NORMAL'

Seems pretty strange to me because MSDN states that it should be supported starting from the DirectX 9:

The following types of semantics are supported in both Direct3D 9 and Direct3D 10 and later

Here's my hlsl file:

float4x4 worldViewProj;
float4 lightPosition;
float3 eyePosition;

struct VS_OUTPUT
{
   float4 pos: POSITION;
   float4 normal: NORMAL;
   float4 color: COLOR;
   float4 lightPosition: TEXCOORD0;
   float3 eyePosition: TEXCOORD1;
   float3 pos3d: TEXCOORD2;
};

VS_OUTPUT main(
    float4 pos: POSITION, 
    float4 normal: NORMAL,
    float4 color: COLOR
)
{
   VS_OUTPUT Out;
   Out.pos = mul(worldViewProj, pos);
   Out.pos3d = pos.xyz;
   Out.normal = normal;
   Out.color = color;

   Out.lightPosition = lightPosition;
   Out.eyePosition = eyePosition;

   return Out;
}

Upvotes: 0

Views: 435

Answers (1)

VuVirt
VuVirt

Reputation: 1917

The link you provided clearly states that NORMAL semantics is only supported as VS input. You may try to pass the normal(s) to the pixel shader using TEXCOORD (TEXCOORD3 for instance) instead.

Upvotes: 3

Related Questions