Sign in to follow this  

Invalid values from VS

Recommended Posts


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[]={

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;

  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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this