OpenGL纹理覆盖材质颜色(OpenGL Texture override material color)

编程入门 行业动态 更新时间:2024-10-23 17:34:23
OpenGL纹理覆盖材质颜色(OpenGL Texture override material color)

我想渲染一个场景并将材质颜色与纹理混合。 我正在使用可编程管道和GLSL,当调用函数texture()时,网格的所有部分都希望没有纹理变得透明。 (即使我不在最终的fragColor中使用vec4)

看下面的screeshots,在第一个图像中我只有材质颜色,在第二个应用的纹理,但只有材料颜色的面变得透明..

在我的片段着色器中,我有类似的东西:

vec4 tex = texture(texsampl,fTexCoord); fFragColor = ambient + (diffuse*tex) + specular;

I want to render a scene and blend the material color with the texture. i am using programmable pipeline and GLSL, when the function texture() is called, all the portion of the meshes wish dont have texture become transparent. (even if i dont use the vec4 in the final fragColor)

look in the screeshots below, in the first image i have only the material color, in the second the applied texture, but the faces with only material color become transparent..

in my fragment shader, i have something like that:

vec4 tex = texture(texsampl,fTexCoord); fFragColor = ambient + (diffuse*tex) + specular;

最满意答案

只有材料颜色变得透明。

好吧,你正在添加值,这就是预期的结果。 你应该使用一些混合函数,比如mix (= s*a + d*(1-a) ,其中s和d是材质和纹理,a是一些混合因子)或slerp 。

only material color become transparent.

Well, you're adding the values, that's what to be expected. You should instead use some blending function like mix (= s*a + d*(1-a) where s and d are material and texture and a is some blending factor) or slerp.

更多推荐

本文发布于:2023-08-05 07:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1430231.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:纹理   材质   颜色   OpenGL   color

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!