Jump to content
  • Advertisement
Sign in to follow this  
bmarci

Invalid values from VS

This topic is 1620 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

Hi,

I'm trying to draw screen aligned quad with pre-transformed vertices and DrawPrimitiveUP.

Some weird is happening to the output values of the vertex shader:

 

Here are some samples:

 

The buffer consist of 4 vertices (screen corners) in the following format:

struct TVertex {
    float pos[3];
    float rhw;
    float uv[2];
};

The pos.xy are set to the screen corners, the pos.z is 0 and the rhw is 1. The UV members are 0,0/1,0/1,1/0,1

And drawing a trianglefan.

 

The vertex declaration is as follows:

const D3DVERTEXELEMENT9 dcl[]={
  {0,0, D3DDECLTYPE_FLOAT4,D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_POSITIONT,0},
  {0,16,D3DDECLTYPE_FLOAT2,D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_TEXCOORD,0},
  D3DDECL_END()
};

And a very simple shader to make the situation clear:

struct VSIn 
  float4 pos: POSITION;
  float2 uv: TEXCOORD;
};

struct VSOut {
  float4 pos: SV_POSITION;
  float4 spec: TEXCOORD0;
};

VSOut VSMain(VSIn input) {
  VSOut output;

  output.pos=input.pos;
  output.spec=float4(1,1,1,1);
  return output;
};

float4 PSMain(VSOut input): SV_TARGET {
  return input.spec;
};

I'd expect the whole screen to be white, but it's not!

It looks like the corners get these "spec" values:   (0,0,0,1) (1,0,0,1) (1,1,0,1) (0,1,0,1)

 

If I use a different register,

float4 spec: TEXCOORD1;

The whole screen is black, the input.spec value is (0,0,0,1)

 

The same shader works fine with "normal" projected transformation, but not with pre-transformed vertices.

 

What do I miss here??

 

Thanks for any help!

 

Share this post


Link to post
Share on other sites
Advertisement

When using pre-transformed vertices (D3DDECLUSAGE_POSITIONT) the vertex shader is skipped and your pixel shader receives what you provide with your vertex buffer(s) directly.

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!