GLSL textureCube和Texture2D在同一着色器中 [英] GLSL textureCube and texture2D in same shader

查看:215
本文介绍了GLSL textureCube和Texture2D在同一着色器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在一个着色器中同时具有texture2D()textureCube().当我这样做时,没有任何显示,也没有错误.我使用自己的着色器加载器和Apple GLSL着色器生成器尝试了此操作,并且发生了相同的事情.即使我在顶点着色器中有textureCube()且在片段中有texture2D(),也会发生这种情况.它们似乎可以正常工作,但是一旦一起调用,无论顺序如何,都不会显示任何内容.

I can't seem to be able to have both texture2D() and textureCube() in one shader. When I do, nothing shows up and there is no error. I tried this both with my own shader loader and the Apple GLSL shader builder and the same thing happens. It happens even if I have textureCube() in the vertex shader and texture2D() in the fragment. They seem to work fine by themselves, but as soon as they're called together, no matter in which order, nothing shows up.

推荐答案

您需要在两个着色器中将这两个纹理作为统一绑定,并分配两个不同的纹理单元,每个纹理单元都将其中一个纹理分配给采样器统一.

You need to bind both textures as uniforms in both shaders and assign two different texture units, each with one of the textures to the sampler uniforms.

这篇关于GLSL textureCube和Texture2D在同一着色器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆