Go Back   AC3D Forums > General > AC3D General
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 27th October 2008, 12:39 PM   #1
jcummings
Junior Member
Junior member
 
Join Date: Jun 2007
Posts: 7
Default Texture clamping and repeating

I'm looking for clarification and/or correction on the clamping of texture and the texrep parameter. In essence, what should the clamping mode be when no texrep parameter is specified? That is, should an image start wrapping around the other side even if the texture coordinates are 1.0?

My question stems from switching from custom OpenGL code to render AC3D models to OpenSceneGraph. Our custom code would set the OpenGL clamping mode to not repeat (CLAMP_TO_EDGE I think) unless there was a texrep line. Well, OSG behaved differently and I'm not sure which one is considered "correct." In this thread on the osg-users list:

http://www.mail-archive.com/osg-user.../msg17192.html

I have attached an example model (may not have show up on the archives yet).

If our custom code behavior is not considered correct, what is the correct way to change the AC3D model?
jcummings is offline   Reply With Quote
Old 27th October 2008, 02:40 PM   #2
jcummings
Junior Member
Junior member
 
Join Date: Jun 2007
Posts: 7
Default Re: Texture clamping and repeating

Here are some screenshots since it appears my message may not have made it into the osg-users mailing list archive.

One screenshot is of the model in AC3D where you can see the repeating a little bit (the one with the grey background). One is of the model rendered in OSG without any clamping (you can see the African desert in the Atlantic and vice versa). The remaining screenshot is of the behavior I am looking for (i.e., texture clamped to edge).
Attached Thumbnails
Click image for larger version

Name:	desired_behavior.jpg
Views:	409
Size:	39.7 KB
ID:	1295  

Click image for larger version

Name:	ac3d_behavior.jpg
Views:	419
Size:	35.9 KB
ID:	1296  

Click image for larger version

Name:	old_behavior.jpg
Views:	375
Size:	39.5 KB
ID:	1297  


Last edited by jcummings; 27th October 2008 at 02:49 PM.
jcummings is offline   Reply With Quote
Old 27th October 2008, 05:15 PM   #3
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default Re: Texture clamping and repeating

Can you point out the specific differences - I'm finding it hard to tell.
Andy is offline   Reply With Quote
Old 27th October 2008, 05:27 PM   #4
jcummings
Junior Member
Junior member
 
Join Date: Jun 2007
Posts: 7
Default Re: Texture clamping and repeating

No problem. If you will notice, the one called "old_behavior.jpg" (which is the one on the bottom) and the one called "ac3d_behavior.jpg" (which is the one in the middle with the grey background) both have a blue line running through the middle of Africa and a sand-colored line running through the Atlantic Ocean.

The image called "desired_behavior.jpg" (which is the first image) does not have these extra lines. It uses the GL setting GL_CLAMP_TO_EDGE to avoid those lines.

Does that help or should I post other images?
jcummings is offline   Reply With Quote
Old 27th October 2008, 05:37 PM   #5
lisa
Senior Member
Professional user
 
lisa's Avatar
 
Join Date: Mar 2005
Location: Phoenix, AZ
Posts: 917
Default Re: Texture clamping and repeating

I think I understand where jcummings is going with this.

jcummings - from purely a graphics programmer perspective, "clamp" would be the correct answer for non-repeating\non-tiling textures. This assumes, however, that you have a rule for your art team that uvs cannot go outside the [0-1], which isn't always the case.

However, I think AC3D has the correct behavior with "wrap" because of the specific use-case. AC3D allows uvs outside [0-1], which it needs to as many formats it imports also allows uvs outside [0-1]. When most artists create texture coordinates outside the [0-1] range, they are assuming it will tile. This is really the only reason an artist would do this, and many people use this "trick" especially with editors that don't support explicit repeat modes.

If you wanted to be really sexy about it on your importer, I would take the min and max of the uv coordinates. If the uvs are within the 0-1 range and repeat mode is disabled, set your addressing mode to "clamp" to minimize seams. If any uvs are outside the 0-1 range, then set your addressing mode to "wrap" and assume it was intentional. This should give you the best of both worlds.
lisa is offline   Reply With Quote
Old 27th October 2008, 05:52 PM   #6
jcummings
Junior Member
Junior member
 
Join Date: Jun 2007
Posts: 7
Default Re: Texture clamping and repeating

lisa- yes, you understand where I am headed with this thread.

I do like the idea of simply testing the UV range. I have done a half-hearted version of this by turning on wrap (GL_REPEAT in my case) when there was a "texrep" line and clamping (GL_CLAMP_TO_EDGE) if it was not present. Clearly I didn't encountered models with larger UV ranges- but it happened to work for my situation. It sounds like testing the range may be all I need to do?

In other words, is testing the UV ranges the best approach or is there another feature that I'm missing in AC3D? Is it simply that the .ac file format doesn't have a formal definition for clamping and it is up to user to figure out the "best" thing to do?
jcummings is offline   Reply With Quote
Old 27th October 2008, 06:03 PM   #7
lisa
Senior Member
Professional user
 
lisa's Avatar
 
Join Date: Mar 2005
Location: Phoenix, AZ
Posts: 917
Default Re: Texture clamping and repeating

Andy can answer that better than I can, but AFAIK there's no formal setting for "clamp" in AC3D.

Testing the range should do the trick though. I'm hard-pressed to think of a common use-case that would be otherwise.
lisa is offline   Reply With Quote
Old 3rd November 2008, 10:35 AM   #8
jcummings
Junior Member
Junior member
 
Join Date: Jun 2007
Posts: 7
Default Re: Texture clamping and repeating

Andy, is there a way to explicitly set the clamp mode or is it ambiguous?
jcummings is offline   Reply With Quote
Old 3rd November 2008, 02:56 PM   #9
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default Re: Texture clamping and repeating

It's fixed to repeat at the moment.
Andy is offline   Reply With Quote
Old 3rd November 2008, 03:07 PM   #10
jcummings
Junior Member
Junior member
 
Join Date: Jun 2007
Posts: 7
Default Re: Texture clamping and repeating

Quote:
Originally Posted by Andy View Post
It's fixed to repeat at the moment.
Should I read something into the "at the moment" portion?

Regardless, a feature to control the repeating/clamping mode would be desirable.

Thanks for the clarification.
jcummings is offline   Reply With Quote
Reply

Tags
clamping, texture, texture clamping, texture repeat

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 06:17 PM.


AC3D Forum
(C) Inivis Limited 2020