Okay, this works:

Case 1
0) set up shader with sampler2D uniform
1) bind 0 to to the sampler uniform (meaning texture unit 0 )
2) set active texture image unit to 0
3) load texture from file and give it an id
4) create an empty texture and give it an id
5) create a framebuffer and bind it to the texture from #3
6) set output framebuffer to this new framebuffer
6) set active texture image unit to 0 again
7) bind texture from #2 to texture image unit 0
8) draw some stuff
9) set output framebuffer back to the screen
10) bind texture from #3 to texture image unit 0
11) draw some more stuff with the same shader.

What you get is the stuff you drew first as a texture on the stuff you drew second.

This, however, doesn't work:

Case 2
0) set up shader with sampler2D uniform
1) set active texture image unit to 0
2) load texture from file and give it an id
3) set active texture image unit to 1
4) create an empty texture and give it an id
5) create a framebuffer and bind it to the texture from #3
6) set output framebuffer to this new framebuffer
7) bind 0 to to the shader's sampler uniform (meaning texture image unit 0 )
8) draw some stuff
9) set output framebuffer back to the screen
10) bind 1 to to the shader's sampler uniform (meaning texture image unit 1 )
11) draw some more stuff with the same shader.

The difference between these two cases is that in the first case we continually rebound the texture image unit to whatever texture we wanted to use while leaving the sampler uniform setting in the shader to a constant value, and in the second case we continually rotate the sampler uniforms' value, but in theory leave the texture image units alone.

The second case seems like it should work, unless I'm missing something. Every device I have tested it on yields a different result, though, making it seem as if you can't change the sampler texture image unit parameter after you've set it.

Should case 2 work? It seems like it should be less expensive to map shader uniforms than texture image units, so obviously I'd prefer to use case 2 in my code if it can be made to work.


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to