Skip to main content
gamedev.net
🔒 Locked

multitexturing

Started by amenzix 2 replies 900+ views
Original Post
amenzix
amenzix
I've googled my brains out, but wasn't able to find anything. i have a few questions 1. How can I mix to textures, say dirt and grass, based on a third grayscale texture? I guess it's based on multitexturing, but I'm absouletly new at this extension. 2. Is it possible to have the fixed-functionality pipeline lighting of OpenGL while using multitexturing? If not I guess I'll have to use lightmaps, right? 3. If it isn't multitexturing, is there a nice way of mixing two textures, on a say, terrain? Like rock on slopes (based on the surface's normal) and grass on plateaux?
PhilMorton
PhilMorton
1) You need to use the multitexture extension (assuming you are using GL).
The NeHe site should have a tutorial on multitexturing i think.

2) Yes. You can use regular lights, or lightmaps, or both.

3) You could do fancy stuff like that with shaders.



The math behind blending "dirt and grass, based on a third grayscale texture" goes something like this:

OutputColour = GrassColour*Greyscale + Dirt*(1-Greyscale)
Allways question authority......unless you're on GameDev.net, then it will hurt your rating very badly so just shut the fuck up.
MARS_999
MARS_999
Quote:
Original post by amenzix
I've googled my brains out, but wasn't able to find anything. i have a few questions

1. How can I mix to textures, say dirt and grass, based on a third grayscale texture? I guess it's based on multitexturing, but I'm absouletly new at this extension.

2. Is it possible to have the fixed-functionality pipeline lighting of OpenGL while using multitexturing? If not I guess I'll have to use lightmaps, right?

3. If it isn't multitexturing, is there a nice way of mixing two textures, on a say, terrain? Like rock on slopes (based on the surface's normal) and grass on plateaux?


If you want to stay with FFP and not shaders then look into combiner functions. e.g.
glActiveTexture(GL_TEXTURE0);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);glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE0);glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PRIMARY_COLOR);glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);


check out

http://www.cs.auckland.ac.nz/~jvan006/multitex/multitex.html

and yes you can use glLighting with Multitexturing, make sure you have your normals setup, you will by default only have per vertex lighting unless you bumpmap your terrain with extensions... BTW what you are asking called blendmaps. These allow you to determine what terrain type you want and where.

HTH
amenzix
amenzix
thanks a lot guys, i'll look into it right now :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.