Same model, different UV's

Started by
5 comments, last by 21st Century Moose 10 years, 1 month ago

Hi all,

I realize this might be an impossible task, but then again, it might be a possible one!

First, I am locked to OpenGLES 1.0 for technical reasons at my company. I realize doing it with a shader would be simple, but unless I want to announce that I'm going to be rewriting the whole core graphical section of the company framework (for which I will get fired), I have to do it some other way.

So here's the issue:

We have a model, all UV'd.

We have some skins of the model baked onto a texture atlas.

At load time, the model gets its UVs adjusted to fit the texture on the atlas so it draws well. Like, we literally have a function that takes UV's in the range of 0-1 and adjusts them to the texture's position on the atlas.

Here's my problem:

I want a way to, on the fly, move those UV's over to another place on the atlas. Because the skins that are backed on the atlas are all the same size, it would be sufficient to simply transform the UV's-- they don't need to be resized or recomputer.

But, because UV's are baked to the XYZ position (a featured designed by a madman), I would literally be stuck either making a whole new model with the UV coordinates, or changing the UV's on the fly.

Because this routine needs to be used to populate a screen that could have a lot of versions of the same object with different skins, both of those objects are prohibitive-- I'd need about a hundred models at worst, or I'd need to manually change the UV's a hundred times.

Since the target is mobile, no good!

So: does there exist some sort of call you can make to translate the texture coordinates before drawing a primitive? Sort of the way you'd set the world matrix to move your model, except for texture coordinates? Answer accepted for either DirectX or OpenGL.

Thanks!

John

Advertisement

Simply don't use atlas for those models and textures and you have no problem.

In that case, the number of texture swaps might become prohibitive as well-- even if I write up a batching system. The low end machine we're targetting is iPad2.

This is probably the solution I'm going to go with, but I did want to exhaust my efforts first. It does seem like a tremendous oversight to not have included some method of transforming UV in the pipeline.

http://www.khronos.org/opengles/sdk/1.1/docs/man/


glMatrixMode — specify which matrix is the current matrix
GL_TEXTURE Applies subsequent matrix operations to the texture matrix stack.

Fan-freaking tastic. Thanks a million Kalle!

Make sure when dealing with GL_TEXTURE matrices, that each texture coord has its own matrix. glActiveTexture(GL_TEXTURE0 - 8) you can set matrices for all of those, so make sure if you do that you reset them or all your textures will get F'd.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Make sure when dealing with GL_TEXTURE matrices, that each texture coord has its own matrix. glActiveTexture(GL_TEXTURE0 - 8) you can set matrices for all of those, so make sure if you do that you reset them or all your textures will get F'd.

I'll add - this is via a glLoadIdentity when done, making sure that the correct texture is active and glMatrixMode is GL_TEXTURE.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement