0

We are porting out dx9 code to dx11 and have followed tutorials as far as getting a triangles on the screen. However, any changes to our vertex shader seem to be ignored, so it always passes through input position and colour.

Even if we do mad things like copy the input colour to the position and set the output colour to purple (below), we still get the original triangle in the middle of the screen as though the vertex shader is just passing through the inputs. Changing values in the pixel shader works fine.

Is it something to do with the semantics ? Or does anyone know of a simple thing I may have forgotten. The shaders definitely compile and load fine, if I put an error in them they don't compile. I'm using fxc.exe to compile them. The shader is below...

Thanks

Shaun

struct VertexInputType
{
    float4 position : POSITION;
    float4 color : COLOR;
};

struct PixelInputType
{
    float4 position : SV_POSITION;
    float4 color : COLOR;
};


PixelInputType VShader(VertexInputType input) 
{
    PixelInputType output;


    // Change the position vector to be 4 units for proper matrix calculations.
    input.position.w = 1.0f;

    // Calculate the position of the vertex against the world, view, and projection matrices.

    output.position = input.color;     

    output.color.x=1;
    output.color.y=0;
    output.color.z=1;
    output.color.w=1;

    return output;
}

float4 PShader(PixelInputType input) : SV_TARGET
{
    float4 outcol;
    outcol.x=0;     //input.color.x;
    outcol.y=input.color.y;
    outcol.z=input.color.z;
    outcol.w=input.color.w;
    return outcol;
}
user3162134
  • 287
  • 1
  • 10

1 Answers1

0

GRRR. Initially I couldn't find the D3DCompilefromFile function as I hadn't included the right lib, AND Microsoft tell you its best to compile offline, so that's what I did - using fxc.exe. Well, for whatever reason, my vertex shader just plain didn't work when compiled offline using fxc.exe - it just passed through its input to its output. I'll sill have to find out why, but I'm now using CompileFromFile and everything works as expected !

user3162134
  • 287
  • 1
  • 10