Jump to content
  • Advertisement
Sign in to follow this  
shamexln

How to handle with vertex which is transformed vertex position in HLSL(VSShader)

This topic is 1125 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm porting D3D9 to D3D11

There are some function in code

##################################################################

struct SCREEN_VERTEX 
{
D3DXVECTOR4 pos;
D3DXVECTOR2 tex;
};
 
    // Ensure that we're directly mapping texels to pixels by offset by 0.5
    // For more info see the doc page titled "Directly Mapping Texels to Pixels"
float fWidth5 = (float)m_d3dPresentParam.BackBufferWidth - 0.5f;
float fHeight5 = (float)m_d3dPresentParam.BackBufferHeight - 0.5f;
 
    // Draw the quad
    SCREEN_VERTEX svQuad[4];
 
    svQuad[0].pos = D3DXVECTOR4(-0.5f, -0.5f, 0.5f, 1.0f);
    svQuad[0].tex = D3DXVECTOR2(0, 0);
 
    svQuad[1].pos = D3DXVECTOR4(fWidth5, -0.5f, 0.5f, 1.0f);
    svQuad[1].tex = D3DXVECTOR2(1, 0);
 
    svQuad[2].pos = D3DXVECTOR4(-0.5f, fHeight5, 0.5f, 1.0f);
    svQuad[2].tex = D3DXVECTOR2(0, 1);
 
    svQuad[3].pos = D3DXVECTOR4(fWidth5, fHeight5, 0.5f, 1.0f);
    svQuad[3].tex = D3DXVECTOR2(1, 1);
 
m_spD3DDevice->SetTexture(0, pTexture);
    m_spD3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
    m_spD3DDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
    m_spD3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, svQuad, sizeof(SCREEN_VERTEX));
    m_spD3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
m_spD3DDevice->SetTexture(0, NULL);

##################################################################

 

Because of D3DFVF_XYZRHW , the vertex is the Transformed vertex position.

How can i do with it in HLSL.

for example in HLSL

struct VS_INPUT

{

float4 Pos: POSITION;  // maybe POSITIONT

};

 

struct PS_INPUT

{

float4 Pos: SV_POSITION;

};

 

PS_INTPUT VS(VS_INPUT input)

{

PS_INPUT output = (PS_INPUT)0;

out.Pos = input.Pos;

return output;

}

 

float4 PS(PS_INPUT input):SV_Target

{

return float4(1.0f, 1.0f,1.0f,1.0f);

 

}

?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!