Jump to content
  • Advertisement
Sign in to follow this  

Is it possible to multi-texture without extra uv coordinates?

This topic is 2800 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,
Okay, everyone knows something like this, right?

typedef struct Vertex2D
float mX;
float mY;
float mZ;

long mDiffuse;

float mTextureU;
float mTextureV;
} Vertex2D;

I want to multitexture... but I'm doing something weird. I want texture stage 1 to basically be multiplied by a single pixel in texture stage 2. Okay, easy enough... I add mTextureU2 and mTextureV2 to my vertex up there, and just set all the U2/V2 coordinates to my single pixel.

So here's my question:

Is there any way I can do this without adding two more floats to my vertex type?

I am not changing those UV's often. They stay the same a long time. There's no good reason for me to send them to the card with every single vertex, when I might have 10,000 vertices, all using mTextureU2=.1,mTextureV2=.37

So... is there any way I could not send them-- but clamp stage 2 to a certain texture coordinate, via stage sets or whatnot?


Share this post

Link to post
Share on other sites
In DirectX I'd use a cbuffer for that. I'm sure OpenGL has an analogous method, but I don't know what it would be called.

Share this post

Link to post
Share on other sites
As stated, in D3D10 or 11 you'd use a cbuffer. In D3D9 or OpenGL you can just set them as regular shader uniforms (or use a UBO in OpenGL 3.x). Texture coords don't necessarily have to come from the vertex structure - they're just a pair of numbers so you can take them from anywhere.

If you're using the fixed pipeline in old OpenGL (with immediate mode) you can set your glMultiTexCoord (GL_TEXTURE1, ...) once every time they change and forget about it after that. This will transfer the extra coords with each glVertex call, because that's how glVertex works, but you won't need to worry about them in your program.

Another option might be to use some texgen/texture matrix tricks to get the right coords coming out. You'd want this if you're using the fixed pipeline with vertex arrays/VBOs in OpenGL or in D3D9. I haven't fully worked it out, but it seems like setting up a texgen (any one should do), followed by a texture matrix scale to bring the generated coords as close to 0 as possible, then a translate to set them to your desired values would work.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!