user959801
user959801

Reputation: 9

iPhone openGL ES 2.0 texturing - setting up multiple textures for fragment shader

I'm nervous to ask this, because I've seen several posts alluding to the answer, but none have worked for me. Apologies if this is repetitive.

I'm trying to access more than one texture (2 at the moment) in my fragment shader on iPhone 4 (OS 4.3). My code is properly setting up the first texture and the shader can read and use it on my model. Once I try to add a second texture, though, it overwrites the first instead of giving me two textures.

Is there a good tutorial on passing multiple textures to a pixel shader in ES2.0 for iphone? I think I'm improperly overwriting the same texture slot or something like that.

My code is messy and lengthy. Much of it is modified online samples. Will clean up later. Thanks!

link: My code excerpts pertaining to texture loading and shader usage

Upvotes: 0

Views: 568

Answers (1)

the swine
the swine

Reputation: 11031

This one is simple. Swap the "//Bind to textures" and "// Get uniform locations." blocks and it should work. The problem is that you are setting values of some uniforms, without knowing their location (which you get in the immediately following step).

So the effect that is happening is not "the one texture being overwritten", but the both samplers contain (the default) 0, so both read the same texture.

Hope this helps.

Upvotes: 2

Related Questions