Sign in to follow this  
Kimani

Textures rendering flat for some reason?

Recommended Posts

A little test program I was working on, after ironing out a few bugs, left me with this new challenge to overcome. Why exactly are the textures I'm applying coming out flat like this? I know it's doing something correctly... the colors it is displaying are not hardcoded, but the flattened color of the texture it should be displaying, somehow. As I haven't begun learning the voodoo of vertex and pixel shaders, I'm just using FVF. The texture coordinates, I am sure, are not something like (0,0) on all the vertices, and I do have D3DFVF_TEX1 thrown into the required places. As far as I can tell it's set up just like any other test I've written that correctly renders a texture... Any ideas as to what could be the problem?

Share this post


Link to post
Share on other sites
Well it looks to me like the texture coordinates are being set to 0,0. If you change the top-left pixel of the texture, you'll probably find that the polys will change to that color.

You said that the verts each had correct texture coordinates, so the problem probably lies in your vertex format.

You have to make sure that your vertex structure has the members in the right order. The order I'm doing them in is:

pos (3 floats)
normal (3 floats)
color (unsigned int)
tex coordinates (2 floats * texture channels)

for the FVF

D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX4

If you're not using one of those, you can safely omit it, just make sure you keep the order the same.

Share this post


Link to post
Share on other sites
No, it should be D3DFVF_TEX1 if you have only one texture ^^
As MSDN say, the x in D3DFVF_TEXx is not an index, but the number of textures coordinates in the FVF.

Share this post


Link to post
Share on other sites
Quote:
Original post by PlayfulPuppy
You have to make sure that your vertex structure has the members in the right order.

That would be the one. Everything is working fine now. Let it be known that the order matters! Which makes sense now that I think about it, although the materials I was learning all this from never really made that clear, or put forth the order all the options that you have availible to you come in.

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