Sign in to follow this  

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

This topic is 2120 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?

[code]
typedef struct Vertex2D
{
public:
float mX;
float mY;
float mZ;

long mDiffuse;

float mTextureU;
float mTextureV;
} Vertex2D;
[/code]

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?

Thanks!

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

This topic is 2120 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.

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