PDA

View Full Version : Nonplanar texture coordinates



CJ Clark
01-14-2007, 12:38 PM
I have a problem where texture coordinates get interpolated wrong at the edge of the screen. The solution that OpenGL faq #10.040 gave me was two options:

1. glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); Didn't work.

2. Make all your texture coordinates non-planar.

What exactly is a non-planar texture coordinate and how would I go about creating them? I haven't been able to find any information anywhere. My sample application is a heightmap where I perform the standard texture projection to generate the texture coordinates (so slopes stretch the texture). I have a Doom 3 hellknight rendering as well and it does NOT skew its texture coordinates. So, I know that non-planar texture coordinates are probably the solution, but I don't know how to create them. Any ideas?

Thanks in advance. :)

Ysaneya
01-14-2007, 01:47 PM
You don't happen to render quads that are not planar ?

CJ Clark
01-15-2007, 09:08 AM
Nope. The heightmap is set up as a straight up triangle strip that I generate using the commonly seen tri-strip method for heightmaps as seen online. That's essentially going down each quad strip and generating a tri-strip from it. The "quads" are non-planar, but given that its not a quad strip, that should be fine.

I'll note, the heightmap shows up just fine on 4+ different machines, but when I put it on a co-workers laptop, the textures screw up at the screen edge.

Any idea what non-planar texture coordinates means?

Bruce Merry
01-16-2007, 01:53 AM
I have no idea what is meant by "non-planar texture coordinates", but the only reason I can think of that clipping a triangle should affect things is if a vertex shader does some non-linear computation (since clipping introduces interpolated vertices along the viewport edge).

Are you using a vertex shader at all? Also what hardware is working and what hardware is failing?

CJ Clark
01-16-2007, 11:03 AM
I'm not using a vertex shader. I am using one for the Doom 3 mesh and it does not break, however it may be using this non-planar texture coordinate thing. However, when not using a vertex shader for my terrain, it breaks on so far only 1 machine. My home box is a 6800 Ultra, another box is a Geforce 4 and the other working box uses the built in graphics on a Dell Workstation PWS340 motherboard.

The non working system is a: Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family

I did another test on his laptop and found some strange results. If I force only 1 texture to be able to be applied to a mesh, then my Doom 3 mesh gets rendered without shaders (by design) and by setting this, the terrain renders correctly. Also, if I then set it to use more than 1 texture, the Doom 3 mesh uses a vertex and pixel shader and the terrain doesn't. The terrain then messes up. Could it be that the shaders aren't properly disabling their profile to render the terrain? If not, could something else with shaders and non-shaders have a conflict like this?

Finally, the terrain is set to have 2 textures, but at all times I only render the first texture, I can't imagine this as a problem as the texture does render and all the poly's on the mesh mess up, not just the ones where the second or first texture are.

Any clues from this? Thanks for the help so far.

knackered
01-16-2007, 11:37 PM
try this for a laugh...
glMatrixMode(GL_TEXTURE);
glLoadIdentity();

Ysaneya
01-17-2007, 12:29 AM
Ah, an integrated Intel card. Can't say i'm surprised. Could be a driver bug..

CJ Clark
01-17-2007, 01:14 PM
I'll have him install the latest drivers. I'll cross my fingers. I'll try the matrix mode thing as well, never heard of using it on textures, not a bad idea. Thanks guys. I'll post the results.