Sign in to follow this  
MoonDemon

Multi-texure, use current z buffer

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this