View Full Version : Another question on multitexturing.
04-17-2007, 06:00 PM
I'm still very shaky on the multi-texturing subject.
I am implementing multi-texturing for detail texturing of terrain. My problem is the overlying texture seems to decrease in visibility compared to the underlying texture as the surface darkens do to GL_LIGHTING.
Producing this: (not sure how clear that is)
I am using these texture Environments.
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, overTexture);
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, underTexture);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT);Thanks in advance!
04-18-2007, 01:59 AM
You could for example turn GL_LIGHTING off and in your base texture include lighting (lightmap with textures combined). I've used this for my current terrain and produces very nice results (I am now switching to another solution with multiple textures: http://www.delphi3d.net/articles/viewarticle.php?article=terraintex.htm)
However I you plan to use the detail texture technique -which I consider a very good start-, I suggest you use Terragen to create your terrain, and export the heightmap. Then render the terrain with an automatic Orthographic View from top (Go to camara options and you will find it, it sets the camera to cover the whole terrain from top to create a base texture). Terragen will render the terrain with lighting and shadows + textures, and so then you can export this render and use it as your base texture. I used a 2048x2048 texture and got nice results. To make the texture look more homoegenous I suggest you edit the texture in Photoshop and apply a Gaussian Blur of 1.5. You could try using also a 1024x1024 if your texture is smaller and a bigger Gaussian Blur factor.
Doing this, having the lightmap already calculated, you can disable GL_LIGHTING and you don't need to specify normals for each vertex, and you solved all the problem.
I hope this helped :)
04-18-2007, 02:22 AM
Originally posted by darkrappey:
My problem is the overlying texture seems to decrease in visibility compared to the underlying texture as the surface darkens do to GL_LIGHTING.
This is because only the overlaying texture is multiplied by lighting. When the lighting darkens, the overTexture texture goes towards black while the the intensity of the underTexture remains the same so it appears as more visible. You need to apply the lighting to the result of the addition. The setup should be something like:
GL_COMBINE_RGB = GL_ADD_SIGNED
GL_SRC0_RGB = GL_TEXTURE0
GL_SRC1_RGB = GL_TEXTURE1
GL_COMBINE_RGB = GL_MODULATE
GL_SRC0_RGB = GL_PREVIOUS
GL_SRC1_RGB = GL_PRIMARY_COLOR
04-18-2007, 05:14 PM
Thanks to both.
I am, in a sense, making a program similar to Terragen so using it to make the height maps kinda defeats the purpose :) The terrain is tightly integrated into the game so the editor needs to be pretty specific to the game. On the other hand, I'm sure Terragen is a lot better as far as terrain editing is concerned.
I could also take the method of calculating light maps in real time, but if it is possible for this way to work I guess I'll be stubborn and stick with it for now.
This is because only the overlaying texture is multiplied by lighting. When the lighting darkens, the overTexture texture goes towards black while the the intensity of the underTexture remains the same so it appears as more visible. You need to apply the lighting to the result of the addition.
That makes perfect sense, thank you for clarifying that in a way I can understand!
I'll try and get it working with those settings.
[EDIT: Tested and it works, thanks again]
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.