DX9 - Really customVertex buffer. True float4 instead of D3DCOLOR

Started by
2 comments, last by #Include Graphics 4 years, 6 months ago

Hey everyone!!

I am wondering if is there any possibility of setting up a true linear colored vertex buffer in DirectX9.

A usual custom vertex buffer in DX9 would be like this:
 


struct VertexBuffer

 {

        D3DXVECTOR3 m_position;
        D3DXVECTOR3 m_normal;
        D3DCOLOR m_color;
        D3DXVECTOR2 m_tex;

}

And what I would like it to be is this:
 


struct VertexBuffer

 {

        D3DXVECTOR3 m_position;
        D3DXVECTOR3 m_normal;
        D3DXVECTOR4 m_color;
        D3DXVECTOR2 m_tex;

}

The problem is that the shading phase with the input is accepting correctly the D3DCOLOR which must be doing something extra internally to transform it. But I am unable to make the second VB type to work properly.


struct VS_INPUT
{
    float3    m_position  : POSITION;
    float3    m_normal    : NORMAL;
    float4    m_color     : COLOR;
    float2    m_uv        : TEXCOORD0;
};

I have already done it in DX11 but I am struggling with DX9.

What am I missing? Maybe DX9 is not ready to do that?

Any help will be welcomed!

Advertisement

Yeah you set it up in basically the same was as in D3D11 -- except in 11 it's called an "Input Layout" and in 9 it's called the "Vertex Declaration". What does your Vertex Declaration / array of D3DVERTEXELEMENT9's look like?

Omg Hodgman, you are right. That was all the problem.

I modified D3DDECLTYPE_D3DCOLOR for D3DDECLTYPE_FLOAT4 and it is fine now.

Thank you so much!

This topic is closed to new replies.

Advertisement