Jump to content
  • Advertisement
Sign in to follow this  
mlt

OpenGL Accessing a GL_LUMINANCE texture?

This topic is 3514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a glTexImage2D call I specify GL_LUMINANCE as the internal format for a grayscale texture. In a Cg vertex shader I then do a lookup: ... float4 h = tex2D(height_texture, uv); ... But how do I get the intensity from the lookup? On this page: http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node51.html the data is stored in a 5th channel called "L" but how do I access this channel when Cg only supports up to float4 vectors?

Share this post


Link to post
Share on other sites
Advertisement
Ok but what are the range of the values returned by tex2D?

If I use GL_LUMINANCE16 I assume the value can be a number between 0 and 255. If I then would apply the color to the OUT.color in the fragment program I would have to do something like:

OUT.color = float(IN.height/255.0, 0.0, 0.0, 0.0);

since the range for the OUT.color in the fragment program must be a number between 0-1.

Or is there some better way to test this?

Share this post


Link to post
Share on other sites
Quote:
Original post by mlt
Ok but what are the range of the values returned by tex2D?

If I use GL_LUMINANCE16 I assume the value can be a number between 0 and 255. If I then would apply the color to the OUT.color in the fragment program I would have to do something like:
Again, not positive for Cg, but textures in GLSL all are in the range [0, 1].

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!