Sign in to follow this  
n0ob

noob doing ps/vs_3_0, not sending data to tex coords

Recommended Posts

Hello folks! I'm new to pixel and vertex shaders. Right now I'm having a stupid issue. Everything is pretty simple in the following example, so it shouldn't be too hard to figure out. I'd really be glad if someone knew what was wrong! Right now I have four vertices, with xyz and uv values. They draw correctly, and my pixel and vertex shaders are shading away. I've narrowed down the problem to this: It's not sending my texture coordinate values to the vertex shader. I think I've set everything up okay... does anyone know what's wrong? //In the cpp... #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_TEX0) struct CUSTOMVERTEX { FLOAT x, y, z; FLOAT u, v; }; //In the fx file... struct VS_OUTPUT { float4 Position : POSITION; float2 Tex : TEXCOORD0; }; VS_OUTPUT RenderSceneVS( float4 vPos : POSITION, float2 vTex : TEXCOORD0) { VS_OUTPUT Output; Output.Position = vPos; Output.Position.w = 1.0f; Output.Tex = vPos.xy; //Can use these values to display color Output.Tex = vTex; //but not these: vTex is always 0,0 return Output; } loat4 RenderScenePS( VS_OUTPUT In) : COLOR0 { return float4(In.Tex.xy, 0, 0); } So, just in case you're curious, I'm making a quad to fill the screen, the declaration of my array looks like this: CUSTOMVERTEX vertices[] = { { 1.0f, 1.0f, 0.5f, xMax, yMax, }, { 1.0f, -1.0f, 0.5f, xMax, yMin, }, { -1.0f, 1.0f, 0.5f, xMin, yMax, }, { -1.0f, -1.0f, 0.5f, xMin, yMin, } }; The x/y min/max are set to +/- 2 (I'm trying to write a fractal zoomer :P). These should be okay for uv coords tho right? I've got an x1800xt, and I'm compiling PS_3_0 and vs_3_0. Thanks for your time!

Share this post


Link to post
Share on other sites
Well, instead of using TEXCOORD0, I'm using NORMAL right now (lol). This allows me to pass my data through the vertices, which makes me think that TEXCOORD0 is not matched to D3DFVF_TEX0 *boggle*

As a side question, why does this crash in my pixel shader?
if(In.Tex.x * In.Tex.x + In.Tex.y * In.Tex.y > 4.0f)

But not this:
if(In.Tex.x * In.Tex.x + In.Tex.y * In.Tex.y - 4.0f > 0)

A bit bogus to me. I can think of some random ideas why, but it doesn't make any practical sense. Anyway, I'm still looking for input and answers to these lame questions. Thanks!

Share this post


Link to post
Share on other sites
What does your D3DVERTEXELEMENT9 look like? It should look something like this:

D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END()
};

Share this post


Link to post
Share on other sites
Btw, my error reporting system was a bit messed up. I know why the > 4.0f line was failing now :P

BUT, I'm not using vertex elements, oh no! Something for me to read up on I suppose? Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this