Archived

This topic is now archived and is closed to further replies.

Vertex colors with multitexturing

This topic is 5270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I''ve got my landscape working with multitexturing, and now it looks really pretty with the detail texture! But the shadows for the landscape are stored in a shadow map which is loaded and then turned into a vertex color array. Now the shadows aren''t working. I guess I have several options for shadows besides the vertex color array, but I don''t like them. I could combine the shadow map onto the texture map for the whole island, but then my plans for several different shadow maps depending on the time of day wouldn''t really be feasable (my shadow map is 256x256 and the texture is 1024x1024!). I could just do multitexturing and put the texture, the detail, and the shadow maps all on top of each other onto the landscape, but I''ve only got a GeForce 2 and it can only multitexture two textures at once (that''s right, isn''t it?). I could do two rendering passes of the landscape, but that would involve rendering the landscape twice, right? Basically cutting my frame rate in half? I miss my vertex color arrays. I''d really like to get them back. Is there a way to use multitexturing with vertex coloring? I''ve tried doing an glEnableClientState(GL_COLOR_ARRAY) and sending the color array for the second texture just like the first, but that didn''t work.

Share on other sites
If you are not using alpha component of primary color and your shadows are not colord you can store shadow in alpha component of primary color. In not, there is still secondary color you could use.

You should never let your fears become the boundaries of your dreams.

Share on other sites
You mean the primary color of the vertex? But wouldn''t changing the alpha of the vertex color change the transparency of the vertex? And what do you mean by secondary color?

Share on other sites
The secondary colour is supported through an EXT extension or through OpenGL 1.4. The geforce2 supports the former I believe.

Here's how you'd do it with the GL Easy Extension Library (tm) .
if (GLEE_EXT_secondary_color){  glEnable(GL_CURRENT_SECONDARY_COLOR);  glSecondaryColor3fEXT(...);}//Or with vertex arrays you'd use glSecondaryColorPointerEXT(...).

[edited by - benjamin bunny on August 18, 2003 6:56:17 PM]

Share on other sites
Thanks for the help! Now I''ve got another, kinda related, question.

When I multitexture (is there a better name for this?) the detail and terrain texture map together, it darkens everything (I''m using GL_MODULATE). Using GL_ADD makes everything REALLY bright. I''m hoping I can only apply the detail texture to areas that are kinda close to the camera, but if adding the detail texture makes the terrain lighter or darker, well, that won''t work!

Is there a way to put the detail texture onto the landscape without affecting the lightness or darkness of everything?

Share on other sites
Well, GL_MODULATE multiplies the colours, so it''s bound to get darker when you use it, unless the detail texture is pure white. To minimise this, you can make the detail texture as bright as possible. Maybe you could also make the geometry which doesn''t have a detail texture slightly darker by modifying the colour. I would be tempted to just leave it unless you''re having real performance problems though.

Share on other sites
No, it runs fast enough for me. I just thought that was kinda the way it was done. Is there any kind of performance hit for multitexturing? I haven''t been able to detect any, but I dunno.

Share on other sites
Yep, but no more than you''d get with GL lighting. Just make sure you use mipmapping for the detail texture.

Share on other sites
the problem with modulating is that it only works in one direction: darker. adding does the same in the other direction.
with register combiners (and most likely fragment programs) you can scale your color to -1,1 instead of 0,1.. allowing you to make it both, darker or brighter. sounds weird but works well.

if you happen to have a geforce with 4 texture units or more (gf3 or above) you can use the editor for the terrain here:

for now it only allows to "draw" on the terrain (left button) or change the weight for the detail textures (right button). rotate with middle button, the three blank sliders are brush size, opacity and fading.