I am trying to make a multi-textured point sprite for an iphone application using OpenGL ES 2.0. I can't find any examples of this on web, and it doesn't seem to be working. Is there some built-in limitation where gl_PointCoord can't be used on multiple textures when using GL_POINTS mode for point sprites?
uniform sampler2D tex; uniform sampler2D blur_tex; vec4 texPixel = texture2D( tex, gl_PointCoord ); vec4 blurPixel = texture2D( blur_tex, gl_PointCoord );
I'm sure I am passing in the textures properly, as I can do multi-texturing just fine in TRIANGLE_STRIP mode, but I am hoping to speed things up using point sprites.
If it is possible, a link to an example of working code would super helpful. Thanks!
EDIT:
Here's how I'm passing in the textures to my shader. This lets me do multi-texturing when I am in TRIANGLE or TRIANGLE_STRIP mode.
//pass in position and tex_coord attributes... //normal tex glActiveTexture(0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex0); glUniform1i(SAMPLER_0_UNIFORM, 0); //blur tex glActiveTexture(1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex1); glUniform1i(SAMPLER_1_UNIFORM, 1); //draw arrays...
However if I am using POINTS mode then I never see the second texture. That is, referring to the shader code above, whether I do
gl_FragColor = texPixel;
OR
gl_FragColor = blurPixel;
I see the same texture. Which seems strange. My guess is that you CAN'T do multi-texturing on a point sprite and somehow having two active textures or two calls to gl_PointCoord causes a problem. But I'm hoping I'm wrong. So if someone has a simple example of multi-texturing working with point sprites in OpenGL ES 2.0 I would be happy to look at that code!
EDIT 2:
vertex shader:
attribute vec4 position; void main() { gl_PointSize = 15.0; gl_Position = position; }
fragment shader:
precision mediump float; uniform sampler2D tex; uniform sampler2D blur_tex; void main() { vec4 texPixel = texture2D( tex, gl_PointCoord ); vec4 blurPixel = texture2D( blur_tex, gl_PointCoord ); //these both do the same thing even though I am passing in two different textures?!?!?!? //gl_FragColor = texPixel; gl_FragColor = blurPixel; }