Detail texturing

Hello all and happy new year!.

I’m trying to do some detail texturing on the triangles closest to the viewpoint for the first time.

I’m doing this in a second pass, and I’m fiddeling with different blend modes like, (GL_ONE, GL_ONE) and (GL_ZERO, GL_SRC_COLOR), but either it gets too bright or too dark.

Ideally the detail texture should fade in smoothly as the triangles approaches the viewpoint.

I’ve tried to change the vertice colors (2nd pass) on the detail triangles depending on distance to the viewpoint but since I got large triangles, a triangle thats close could have the vertices far away.

Well, any help appreciated!

Unless you use all your texture units, you can do it with the ARB_texture_env_combine extension. That extension has a texture function GL_ADD_SIGNED (instead of GL_REPLACE, GL_MODULATE, and so on), which is great for detail mapping.

You can also use blending, but you have to make sure the texture is correct. If you use additive blending (GL_ONE, GL_ONE), your detail texture must be very dark, otherwise you get some very bright spots. If you use multiplicative blending (GL_ZERO, GL_SRC_COLOR), your detail texture must be very bright, otherwise the dark parts of the detail texture will result in very dark spots in the resulting image.

If you want to fade the detail texture, you really should have a look at the ARB_texture_env_combind. You can fade the detail texture using the primary color, and then either add or multiply the resulting detail with the framebuffer.

Just remember, if you use additive blending, you cannot darker results than what’s already in the framebuffer, and with multiplicative blending, you cannot get brigher result.