Douglass Turner
10-27-2010, 02:14 PM
Hi,
I am writing shaders for OpenGL ES on iPhone OS. Within a fragment shader I was shocked to discover the following:
These all work:
vec4 rgba = texture2D( myRGBATexture, v_st);
float r = texture2D( myRGBATexture, v_st).r;
float g = texture2D( myRGBATexture, v_st).g;
float b = texture2D( myRGBATexture, v_st).b;
These ALL return a constant value of zero (0), ignoring the contents of the one channel texture (!?!). Note, at texture creation time OpenGL says I have a texture colr as GL_ALPHA and data type as GL_UNSIGNED_BYTE:
float a = texture2D( myOneChannelTexture, v_st).r;
float a = texture2D( myOneChannelTexture, v_st).g;
float a = texture2D( myOneChannelTexture, v_st).b;
float a = texture2D( myOneChannelTexture, v_st).a;
Can someone please explain why GLSL forces me to waste tons of memory with a 3-channel texture when a 1-channel texture is all I need?
Thanks,
Doug
I am writing shaders for OpenGL ES on iPhone OS. Within a fragment shader I was shocked to discover the following:
These all work:
vec4 rgba = texture2D( myRGBATexture, v_st);
float r = texture2D( myRGBATexture, v_st).r;
float g = texture2D( myRGBATexture, v_st).g;
float b = texture2D( myRGBATexture, v_st).b;
These ALL return a constant value of zero (0), ignoring the contents of the one channel texture (!?!). Note, at texture creation time OpenGL says I have a texture colr as GL_ALPHA and data type as GL_UNSIGNED_BYTE:
float a = texture2D( myOneChannelTexture, v_st).r;
float a = texture2D( myOneChannelTexture, v_st).g;
float a = texture2D( myOneChannelTexture, v_st).b;
float a = texture2D( myOneChannelTexture, v_st).a;
Can someone please explain why GLSL forces me to waste tons of memory with a 3-channel texture when a 1-channel texture is all I need?
Thanks,
Doug