Skip to main content
gamedev.net
🔒 Locked

Multi-texure, use current z buffer

Started by MoonDemon Sep 30, 2010 at 6:53 PM 2 replies 650+ views
Original Post
MoonDemon
MoonDemon
I am currently using multi-texturing to set the alpha value to a particular value based on distance. I do this by generating texture coordinates from the z distance.

glEnable( GL_TEXTURE_GEN_S );
glTexGend( GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
GLfloat texgen[] = {0.0, 0.0, -1/oglFarplane, 0.0};
glTexGenfv( GL_S, GL_EYE_PLANE, texgen );
glEnable( GL_TEXTURE_1D );
glBindTexture( GL_TEXTURE_1D, texHandle );

-- glTexEnv calls to specify combination rules

This all works fine but it prevents me from using alpha values elsewhere in my scene. What I would like to be able to do is to render a fullscreen quad and generate the texture coordinates using the current z buffer instead of the z distance of the texels in the quad.

Any ideas?
karwosts
karwosts
I don't totally get what you mean by 'the current z buffer instead of the z distance of the texels', but it sounds like you need to start taking a look at shaders. They should be flexible enough to do whatever it is you are trying to do, and I believe all this texenv stuff has been long deprecated.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
MoonDemon
MoonDemon
I have been pointed towards shaders at every question related to this, and yes I could just go ahead and use them, I was just trying to maximise compatibility and will avoid them until I can't any longer.

I am generating a texture coordinate using a texel's z distance. I want to generate a texture coordinate using the z buffer instead.
karwosts
karwosts
Quote:

I have been pointed towards shaders at every question related to this


Do you think there might be a reason why? :)

In all honesty it's up to you what you want to do, but seriously shading languages have been around since like 2003, even opengl arb has abandoned the fixed pipeline, its abandoned and nobody uses it anymore. To purposely avoid it seems masochistic to me, unless you are marketing whatever you're doing to computers that are 10 years old.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

Topic Locked

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

Sign in to reply to this topic.