PDA

View Full Version : Various OpenGL Questions


Jake
2004.09.19, 12:05 PM
I'm not very happy with my uDevGames terrain engine right now, the LOD and terrain itself look great, but the texturing is pretty bad. At first I just tiled different tiles like in GL Golf, and then I moved to a big 1024x1024 texture to stretch over the entire map with a detail texture, and again that looks bad.

What I want to do is use 2-4 texture units to blend my tiles together, which are based off of height and slope. Here are my options

1. Use only two textures to blend together and use my vertex lighting. Fast
2. Use 3 textures, a light map, and my two tiles

I am leaning towards 1 right now because geforce 2 cards only have 2 texture units.


Now first I am going to fix all the rough edges in GL Golf with the tile blending to figure out how to do this, but I am confused on how to do this fast. Right now I am using glBegin(GL_TRIANGLSE) 5 times, one for each texture type. Is there a way to keep this method, or am I going to have to switch to vertex arrays (which will be much faster anyways).

Now lets just assume I am using vertex arrays, how would I do that, would I need an array for each texture, then each T1-T2,T1-T3, ect mixture? And does anyone have a small snippet of code that blends two textures together with weighted vertexes I can see please?

Thanks for the help in advance

arekkusu
2004.09.19, 05:08 PM
Multi-texturing on Terrains (http://www.cs.auckland.ac.nz/~jvan006/multitex/multitex.html)

Jake
2004.09.19, 05:57 PM
Thanks, Too bad they don't have all of the source code but that seams fast and looks good.

Jake
2004.09.19, 06:44 PM
OK, I got the detail and light/surface map done, and I know how to send the UV and XYZ coordinates, but what about the color for the mixmap?

glMultiTexCoord2fARB( GL_TEXTURE0_ARB,
glMultiTexCoord2fARB( GL_TEXTURE1_ARB,
glVertex3f(

arekkusu
2004.09.19, 07:41 PM
man glColor.

[Edit: forums are ******** and don't allow non-http URLs]
[ModEdit: Try just typing in "x-man-page://3/glColor"; in safari, highlight, rightclick,goto

Jake
2004.09.19, 07:46 PM
Broken Link???

Mark Levin
2004.09.20, 02:30 AM
Not sure if your Geforce 2 supports it, but you could also use a 3D texture with a very small vertical dimension (say, 4).

OneSadCookie
2004.09.20, 04:33 AM
x-man-page://3g/glColor

silly forum :)

still, it only opens it in terminal... any way to make Xcode the default for such links?

arekkusu
2004.09.20, 05:41 AM
Geforce2MX/4MX do not support 3D textures; nvidia started supporting them with the GF3.
Yes, this is in spite of the reported MAX_3D_TEXTURE_SIZE value-- it's lying.

Jake
2004.09.20, 09:07 PM
Well I am almost finished with implementing that tutorial arekkusu, but I have came to some problems. First off I DID convert all my mixmap and detail textures from 0-255 and 0-1 to 128-255 and 0.5-1 . Basically I am getting these results

Mixmap 1 A combination of 1-2
Mixmap 2 A combination of 1-2
Mixmap 3 A combination of 1-2-3
Any mixture - A combination of 1-2-3

I would love to figure this out tonight because my senior project meeting is tomorrow and my computer illiterate teacher would appreciate nice graphics instead of half way working mixed textures. But if I don't get it fixed thats OK.

Jake
2004.09.21, 09:21 PM
OK, I have came to the conclusion that my glColor3f() is not effecting my program at all, because I have changed all the values to constants and get the same result. Can someone tell me if this code is doing what I want?

Take the value of the glColor3f and dot3ing it to mix all 3 detail textures, and then mix that result with the lightmap.


glActiveTexture(GL_TEXTURE0);
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[tdetail] );

glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

glActiveTexture(GL_TEXTURE1);
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[theightmap] );

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_ONE_MINUS_SRC_COLOR);

arekkusu
2004.09.22, 04:21 AM
Mm. Do you have a standalone project (no SDL etc) to share? I don't feel like implementing this myself from scratch.

Jake
2004.09.22, 01:11 PM
I will post something when I get home tonight.