First thing's first, this is my very first post here so I'm not really sure of how things work here so bear with me a little! I don't normally resort to forums but I've been stuck with this for a few days now with no success and it's driving me up the wall!
Okay so basically what I'm attempting to do is read some values from an SRV in a vertex shader. I am doing this without setting a vertex buffer or input layout. So they are both null. The data is just an array of float4s that hold a position of a particle.
Here is my vertex and pixel shader:
cbuffer ConstantBuffer : register(b0)
{
matrix World;
matrix View;
matrix Projection;
}
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
struct VS_INPUT
{
uint id : SV_VERTEXID;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float4 Col : COLOUR;
};
struct particles
{
float4 position : POSITION;
};
StructuredBuffer<particles> particlesIn : register(t0);
PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output = (PS_INPUT)0;
uint index = input.id;
particles p = particlesIn[index];
output.Pos = mul(p.position, World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
output.Col = float4(1.0f, 1.0f, 1.0f, 1.0f);
return output;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS(PS_INPUT input) : SV_Target
{
return input.Col;
//return float4(1.0f, 1.0f, 0.0f, 1.0f);
}
Now here's the thing - I pass a value of (0.0f,0.0f,0.0f,0.0f) into this and I get a white point in the centre of the screen. This is the correct behaviour. However, if I change any one of the x,y or z values (by any value it can be as small as 0.000001f or even smaller) I get a blank screen with no point whatsoever. Now I thought it might be to do with some of the matrices that I'm using, but I have tested it out with another program and they are fine. At this point I'm out of ideas, I've tried all sorts to get it working, including using the graphics debugger to look through values that are being passed through the vertex shader. To my surprise they were actually correct! (I think?) What I have posted is just the shaders. If I need to post any other code for you to look at please let me know. I'm desperate for new ideas to take this forward!
Thanks in advance!