1D texture to fade a scene

Started by
0 comments, last by MoonDemon 14 years, 2 months ago
With reference to this old thread http://www.gamedev.net/community/forums/topic.asp?topic_id=556895 I figured that the first test would be to see if I could shade a scene based on the depth value, so rather than playing with alpha values, I have created a 1D texture and I am attempting to texture my scene so that the greater the z distance, the lighter the colour. My 1d texture is effectively a gradient. However, I can't seem to make this work. function BeginDraw() gl.Clear( gl.COLOR_BUFFER_BIT ) gl.Clear( gl.DEPTH_BUFFER_BIT ) gl.LoadIdentity() -- Test multitexturing gl.TexParameter(gl.TEXTURE_1D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) gl.Enable(gl.TEXTURE_GEN_S) gl.TexGen(gl.S, gl.TEXTURE_GEN_MODE, gl.EYE_LINEAR) gl.TexGen(gl.S, gl.EYE_PLANE, 0.0, 0.0, -1/75, 0.0 ) gl.Enable(gl.TEXTURE_2D) gl.BindTexture(gl.TEXTURE_1D, textureArray["FogTexture"]) end ( I am using a LUA binding ). The s coordinate is still being generated from the x coordinate, not the z coordinate, so I get a split screen effect with the start colour taking up most of the left and the end colour taking up most of the right. Any ideas why it's not being generated from the z coordinate?
Advertisement
Ah. Turned out to be a lua issue :$ This code does seem to work fine in case someone else is looking to use it. Hopefully I will be able to create this fade to sky box effect using multitexturing. I will post an update if I manage to get this working.

This topic is closed to new replies.

Advertisement