OpenGL-在顶点着色器或片段着色器中进行纹理映射? [英] OpenGL - Texture mapping in vertex or fragment shader?

查看:534
本文介绍了OpenGL-在顶点着色器或片段着色器中进行纹理映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否在片段着色器或顶点着色器中映射了对象/三角形的纹理?

Is there texture of an object/triangles mapped in the fragment shader or the vertex shader?

无论是在顶点着色器还是片段着色器上,如果要对着色器进行编程,都必须自己编写正确的代码?没有着色器,您只是在不知道的情况下就打开了tex坐标并使用opengl对其进行映射,但是使用着色器,您必须自己进行操作,对吧?

Whether if it is on the vertex or fragment shader, if you are programming shaders it's something that you have to code yourself right? Without shader you just assinged the tex coords and opengl mapps it without you knowing, but with shaders you have to do it yourself, right?

推荐答案

通常,纹理化发生在片段着色器中.这是三角形的碎片变色的地方.

Usually the texturing happens in the fragment shader. This is the place where triangle's fragments gain a color.

通常,在顶点着色器中,您可以计算纹理坐标(或直接从顶点属性传递纹理坐标,而无需进行特殊计算).

Usually in the vertex shader you calculate texture coords (or simply pass them through from vertex attribs without special computation).

我通常写 ,因为现在您可以在所有着色器中使用纹理:顶点,几何形状,镶嵌.

I wrote usually because right now you can use textures in all shaders: vertex, geometry, tesselation.

有关更多信息,请参见此处.

See here for further information.

这篇关于OpenGL-在顶点着色器或片段着色器中进行纹理映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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