Decided to try drawing just a grid for now based on what I could find on rastertek. In short...not getting anywhere.

Here is my shader:

//blend state
BlendState SrcAlphaBlendingAdd
{
BlendEnable[0] = TRUE;
SrcBlend = SRC_ALPHA;
DestBlend = INV_SRC_ALPHA;
BlendOp = ADD;
SrcBlendAlpha = ZERO;
DestBlendAlpha = ZERO;
BlendOpAlpha = ADD;
RenderTargetWriteMask[0] = 0x0F;
};
RasterizerState CLR
{
FillMode = SOLID;
CullMode = NONE;
FrontCounterClockwise = false;
DepthBias = false;
DepthBiasClamp = 0;
SlopeScaledDepthBias = 0;
DepthClipEnable = TRUE;
ScissorEnable = false;
MultisampleEnable = false;
AntialiasedLineEnable = TRUE;
};
//VERTEX AND PIXEL SHADER INPUTS
//--------------------------------------------------------------------------------------
struct SPRITE_INPUT
{
float2 pos : ANCHOR;
};
//pixel shader inputs
struct PS_INPUT
{
float4 p : SV_POSITION;
float2 t : TEXCOORD;
};
float4x4 view;
float4x4 prj;
float dist = 92.77443083f;
//--------------------------------------------------------------------------------------
// VERTEX SHADER
//--------------------------------------------------------------------------------------
PS_INPUT VS( SPRITE_INPUT input )
{
PS_INPUT vert;
float offset = dist*-40.0f;
if((uint)input.pos.x % 2 == 0)
vert.t.x = 0;
else
vert.t.x = 1;
if((uint)input.pos.y % 2 == 0)
vert.t.y = 0;
else
vert.t.y = 1;
vert.p = float4(offset+(input.pos.x*dist), 0, offset+(input.pos.y*dist), 1);
vert.p = mul(vert.p, view);
vert.p = mul(vert.p, prj);
return vert;
}
//--------------------------------------------------------------------------------------
// PIXEL SHADER
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input ) : SV_Target
{
float4 color = float4(1, 1, 1, 1);
if(input.t.x == 0 && input.t.y == 0)
color.gb = 0;
if(input.t.x == 1 && input.t.y == 0)
color.rb = 0;
if(input.t.x == 0 && input.t.y == 1)
color.rg = 0;
return color;
}
//--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------
technique10 RENDER
{
pass P0
{
SetVertexShader( CompileShader( vs_5_0, VS() ) );
SetPixelShader( CompileShader( ps_5_0, PS() ) );
SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetRasterizerState(CLR);
}
}

Here is the code that loads the vertex and index buffer. Its probably the worst way to set things up but I unfortunately cant seem to find anything that helps.

VERTS *vert = new VERTS[38400];
unsigned long *ind = new DWORD[38400];
int index = 0;
for(int j = 0; j < 79; j ++)
{
for(int i = 0; i < 79; i ++)
{
vert[index].x = (float)i;//Upper Left
vert[index].y = (float)j;
ind[index] = index;
index ++;
vert[index].x = (float)i+1;//Upper Right
vert[index].y = (float)j;
ind[index] = index;
index ++;
vert[index].x = (float)i+1;//Lower Right
vert[index].y = (float)j+1;
ind[index] = index;
index ++;
vert[index].x = (float)i+1;//Lower Right
vert[index].y = (float)j+1;
ind[index] = index;
index ++;
vert[index].x = (float)i;//Lower Left
vert[index].y = (float)j+1;
ind[index] = index;
index ++;
vert[index].x = (float)i;//Upper Left
vert[index].y = (float)j;
ind[index] = index;
index ++;
}
}
D3D11_BUFFER_DESC bd;
ZeroMemory(&bd, sizeof(bd));
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof(vert)*38400;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
D3D11_SUBRESOURCE_DATA sv;
ZeroMemory(&sv, sizeof(sv));
sv.pSysMem = &vert[0];
dev->CreateBuffer(&bd, &sv, pvb);
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.ByteWidth = sizeof(ind)*38400;
sv.pSysMem = &ind[0];
dev->CreateBuffer(&bd, &sv, pib);
delete vert;
delete ind;

And here is the result.

If I move or rotate the view matrix position around I get the expected results so it that part is behaving itself. Its pattern that is going bad.

The desired image is a bunch of quads in an orderly 80x80 grid with each corner being a different color.

**Edited by Naruto-kun, 17 June 2014 - 07:44 AM.**