iPhone openGL ES 2.0 纹理 - 为片段着色器设置多个纹理
我很紧张地问这个,因为我看过几个帖子暗指答案,但没有一个对我有用。如果这是重复的,我们深表歉意。
我正在尝试在 iPhone 4 (OS 4.3) 上的片段着色器中访问多个纹理(目前有 2 个)。我的代码正确设置了第一个纹理,着色器可以在我的模型上读取和使用它。但是,一旦我尝试添加第二个纹理,它就会覆盖第一个纹理,而不是给我两个纹理。
有没有关于在 iPhone 的 ES2.0 中将多个纹理传递给像素着色器的好教程?我认为我不正确地覆盖了相同的纹理槽或类似的东西。
我的代码又乱又长。其中大部分是修改过的在线示例。稍后会清理。 谢谢!
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个很简单。交换“//绑定到纹理”和“//获取统一位置”。块并且它应该可以工作。问题是您正在设置某些制服的值,而不知道它们的位置(您将在接下来的步骤中获得)。
因此,发生的效果不是“一个纹理被覆盖”,而是两个采样器都包含(默认)0,因此两者都读取相同的纹理。
希望这有帮助。
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.