具有多个纹理的 gl_fragColor
我目前有两个纹理应用于单个对象。最终还会添加更多的内容,但我很难让当前的两个正常工作。
目前,我正在将我的碎片颜色设置为添加在一起的两个图像。从字面上看,我所做的就是类似的事情:
gl_FragColor = texture1 + texture2;
我确信有一种更好的方法可以开始做这些事情,但它也产生了图像重叠添加在一起的问题(显然),这不是我做的尝试做我当前的项目。
我不确定这是否只是我的 fragColor 的问题,其中有 GLSL 的一些内置函数可以执行类似的操作,或者我是否需要执行一些操作,例如以其他方式预先组合图像。
编辑::我的意思是添加颜色的示例:https://i.sstatic .net/auHMK.png
I currently have two textures being applied to a single object. Eventually there will be a couple more added to that, but I am having trouble getting the current two to work properly.
At the moment, I am setting my fragcolor to the two images added together. Literally all I am doing is something similar to :
gl_FragColor = texture1 + texture2;
I am sure there is a better way to do such things to begin with, but it also creates the problem that where the images overlap is added together (obviously), which is not what I am trying to do with my current project.
I am not sure if this is simply an issue with only my fragColor, where there's some built in function of GLSL to do something like this, or if I need to do something like combine the images before hand in some other fashion.
EDIT :: Example of the color adding I meant : https://i.sstatic.net/auHMK.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您想在着色器中混合两个纹理,而不是通过常规混合进行混合。我相信这样的东西应该有效 - 如果你做出假设,你可能可以简化它。
编辑:
这里的最终答案是常规混合,而不是在片段着色器中混合。
I take it you want to blend the two textures in the shader instead of doing it with regular blending. Something like this should work, I believe - you can probably simplify this if you make assumptions.
EDIT:
The final answer here ended up being regular blending, and not blending in the fragment shader.