How to read BC4 texture in GLSL?
Posted
by
Question
on Game Development
See other posts from Game Development
or by Question
Published on 2012-11-02T15:58:24Z
Indexed on
2012/11/02
17:33 UTC
Read the original article
Hit count: 394
glsl
|fragment-shader
I'm supposed to receive a texture in BC4 format. In OpenGL, i guess this format is called GL_COMPRESSED_RED_RGTC1.
The texture is not really a "texture", more like a data to handle at fragment shader.
Usually, to get colors from a texture within a fragment shader, i do :
uniform sampler2D TextureUnit;
void main()
{
vec4 TexColor = texture2D(TextureUnit, vec2(gl_TexCoord[0]));
(...)
the result of which is obviously a v4, for RGBA.
But now, i'm supposed to receive a single float from the read. I'm struggling to understand how this is achieved.
Should i still use a texture sampler, and expect the value to be in a specific position (for example, within TexColor.r ?), or should i use something else ?
© Game Development or respective owner