Quote:Original post by cNoob
From what I understand, the PixelShader should recieve the VertexShader output so you might need to rewrite the function headers. Also not sure if this would make a difference but I'm sure your aware a UV is only 2 floats, so you could try using float2 instead of float4. I just wrote this, with those changes:
*** Source Snippet Removed ***
I've never done anything shader related so this may or may not work, worth a try. You might want to look at the shader part of Riemers tutorial. It seems as though a sampler is not a texture, you need both a texture and a sampler.
OK changed my efect file to this to add in the sampler
float4x4 WorldViewProjection : WORLDVIEWPROJECTION;struct VS_OUTPUT{ float4 Pos : POSITION; float2 UV : TEXCOORD0;};struct PS_OUTPUT{ float4 Color : COLOR0;};Texture Tex;sampler coloredtexture = sampler_state{ Texture = <Tex>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = mirror; AddressV = mirror;};VS_OUTPUT VShader(float4 Pos : POSITION, float2 UV : TEXCOORD0){ VS_OUTPUT Out; Out.Pos = mul(Pos, WorldViewProjection); Out.UV = UV; return Out;}PS_OUTPUT PShader(float2 UV : TEXCOORD0){ PS_OUTPUT Out; Out.Color = tex2D(coloredtexture, UV); return Out;}technique RenderScreen{ pass P0 { vertexshader = compile vs_2_0 VShader(); pixelshader = compile ps_2_0 PShader(); }}
starting to think its somthing else then the shader code tho. My vertex usually consists of position+normals+texcoords, I decided to remove the normals from everything, and now instead of drawing just the top line, it's drawing just the far left side. I'm pretty sure I'm setting everything right maybe it's not reading from the vertex buffer correctly?
This is my declaration
D3DVERTEXELEMENT9 dec[3] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION,0}, {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,0}, D3DDECL_END() };
This is how I create my vertex buffer
(*m_d3ddev)->CreateVertexBuffer(sizeof(sZOLOVERTEX) * 6000, NULL, 0, D3DPOOL_MANAGED, &m_vertex_buffer, NULL);
I use an orthographics projection that's setup like this
D3DXMATRIXA16 world, view, proj; D3DXMatrixIdentity(&view); D3DXMatrixOrthoLH(&proj, CGraphics->Width(), CGraphics->Height(), 0, 1); D3DXMatrixIdentity(&world); m_world_view_proj = world * view * proj;
I fill the vertex buffer with this
vertices[batch_size].pos = D3DXVECTOR3(ZRP.x1, ZRP.y1, 0); vertices[batch_size].uv = D3DXVECTOR2(m_iterator->sprite->tx1, m_iterator->sprite->ty1); vertices[batch_size + 1].pos = D3DXVECTOR3(ZRP.x2, ZRP.y2, 0); vertices[batch_size + 1].uv = D3DXVECTOR2(m_iterator->sprite->tx2, m_iterator->sprite->ty1); vertices[batch_size + 2].pos = D3DXVECTOR3(ZRP.x4, ZRP.y4, 0); vertices[batch_size + 2].uv = D3DXVECTOR2(m_iterator->sprite->tx2, m_iterator->sprite->ty2); vertices[batch_size + 3].pos = D3DXVECTOR3(ZRP.x1, ZRP.y1, 0); vertices[batch_size + 3].uv = D3DXVECTOR2(m_iterator->sprite->tx1, m_iterator->sprite->ty1); vertices[batch_size + 4].pos = D3DXVECTOR3(ZRP.x4, ZRP.y4, 0); vertices[batch_size + 4].uv = D3DXVECTOR2(m_iterator->sprite->tx2, m_iterator->sprite->ty2); vertices[batch_size + 5].pos = D3DXVECTOR3(ZRP.x3, ZRP.y3, 0); vertices[batch_size + 5].uv = D3DXVECTOR2(m_iterator->sprite->tx1, m_iterator->sprite->ty2);
any ideas?