Is it possible to index between vertices on the vertex shader in order to dynamically offset the output position, it doesn’t seem to be doable.
What shader stage would this be possible in or is it simply not possible in any shader stage.
Considering this is a single very average rectangle quad and between the vertices i want to change the x coordinate by offseting the x position depending on a array look up.
VertexShaderOutput MainVS(in VertexShaderInput input)
{
VertexShaderOutput output = (VertexShaderOutput)0;
float4x4 vp = mul(View, Projection);
float4 pos = mul(input.Position, World);
// more then 10 values in the array doesn't work only looks at the first and second indexs.
pos.x += WorldLights[pos.y].x;
pos = mul(pos, vp);
output.Position3D = pos;
output.Position = pos;
return output;
}
float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 col = float4(0.0f, 0.0f, 0.0f, 0.0f);
float depthMag = input.Position3D.z;
col.r = depthMag;
col.g = 1.0f;
col.b = 1.0f;
col.a = 1.0f;
return col;
}
in game 1
public static Vector2[] WorldLights = new Vector2[10]
{
new Vector2(100, 0),
new Vector2(0, 0),
new Vector2(400, 300),
new Vector2(400, 300),
new Vector2(400, 300),
new Vector2(400, 300),
new Vector2(400, 300),
new Vector2(400, 300),
new Vector2(400, 300),
new Vector2(400, 300)
};
I have three ways i can get around the issue but if i could somehow change the interpolation via a index by telling the vertex shader to evaluate the index in the interpolation that would be optimal.
All the other solutions come with some sort of price and or are more expensive and less efficient.