Jump to content

  • Log In with Google      Sign In   
  • Create Account


Same model, different UV's


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Raptisoft   Members   -  Reputation: 171

Like
0Likes
Like

Posted 10 March 2014 - 04:44 PM

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

 

 

 

 

 



Sponsor:

#2 kalle_h   Members   -  Reputation: 1280

Like
0Likes
Like

Posted 10 March 2014 - 04:48 PM

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



#3 Raptisoft   Members   -  Reputation: 171

Like
0Likes
Like

Posted 10 March 2014 - 04:50 PM

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.


Edited by Raptisoft, 10 March 2014 - 04:50 PM.


#4 kalle_h   Members   -  Reputation: 1280

Like
7Likes
Like

Posted 10 March 2014 - 05:04 PM

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.


#5 Raptisoft   Members   -  Reputation: 171

Like
0Likes
Like

Posted 10 March 2014 - 05:47 PM

Fan-freaking tastic.  Thanks a million Kalle!



#6 dpadam450   Members   -  Reputation: 842

Like
1Likes
Like

Posted 11 March 2014 - 11:39 AM

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.



#7 mhagain   Crossbones+   -  Reputation: 7468

Like
0Likes
Like

Posted 11 March 2014 - 05:24 PM

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.


Edited by mhagain, 11 March 2014 - 05:26 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS