glTexEnv help

Bossa Nova
Unregistered
 
Post: #1
Can someone please clue me in on how to use glTexEnv when accessing multiple texture units. The man page seems to be incomplete.

Basically I want to interpolate between two textures based on the hight of a terrain. At high points one texture should be used completely and at low points the other. In between they should be blended together.

I think I should be able to use GL_INTERPOLATE with glTexEnv to interpolate between the textures but I can't figure out how to.

Thanks for any help.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You probably need three texture units to do this (what card are you running on?)

The extension registry http://oss.sgi.com/projects/ogl-sample/registry/ is the best source of documentation on this stuff. Look at ARB_texture_env_combine.
Quote this message in a reply
Bossa Nova
Unregistered
 
Post: #3
I've got 3 units but preferred only to use the two (keep the reqs lower). Why do you say I'd need three?

BTW, I'm pouring over the spec. Thanks for the link.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Actually, if you pass the height in in the vertex color, you should be able to get away with 2 texture units.

So scale the terrain height to [0..1], and pass it in as the vertex color (r=height, g=height, b=height, alpha=don't care).

Set up the first texture unit source0 to be texture, mode to be replace. Set up the second texture unit source0 to be previous, source1 to be texture, source2 to be primary color, and mode to be interpolate. Ignore all the options for alpha.
Quote this message in a reply
Member
Posts: 177
Joined: 2002.08
Post: #5
Use glActiveTextureARB() to switch the texture unit commands are directed to. glTexEnv*() will work with the last unit selected.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  glTexEnv GL_BLEND inversing texture NitroPye 4 4,325 Jun 12, 2005 09:04 PM
Last Post: NitroPye
  Blending versus glTexEnv(GL_BLEND) WhatMeWorry 5 6,439 Nov 10, 2004 12:13 AM
Last Post: arekkusu