如何设置 openGL 混合,以便可以使用具有一定透明度的 CCSprite 仅在 CCRenderTexture 上的不透明区域上进行绘制?
由于我使用的混合,我在使用包含透明度的纹理绘制 CCRenderTexture 时遇到问题。
我正在绘制的精灵具有以下混合函数:
glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA)
。
它所绘制的渲染纹理具有混合函数:
glBlendFuncSeparate(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA)
。
渲染纹理设置为大部分透明,上面有一些完全不透明的区域。上面的混合函数允许我在实心区域上使用完全实心的精灵进行绘制,而不在透明区域上进行绘制。
当我尝试更改绘制的精灵以包含一些透明度时,就会出现问题。它倾向于“擦除”渲染纹理上的不透明区域。理想情况下,我希望我绘制的精灵上的透明区域没有效果。我想知道 openGL 混合大师是否能够给我一些指导?
为了澄清,我想要实现的最终效果是能够绘制一个精灵,其中包含渲染纹理的一些透明区域。精灵的透明区域不应绘制到我的渲染纹理。仅当精灵的不透明区域位于渲染纹理上的不透明区域上方时,才应绘制到渲染纹理。
I'm having trouble drawing to a CCRenderTexture with a texture that includes transparency due to the blending that I've used.
The sprite that I am drawing with has a blending function of:
glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA)
.
The render texture that it is drawing to has the blending function:
glBlendFuncSeparate(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA)
.
The render texture is set up with it being mostly transparent with some completely opaque areas on it. The above blend functions allow me to draw with a completely solid sprite on the solid areas while it not drawing on the transparent areas.
Trouble arises when I try to change the sprite that I draw with to include some transparency. It tends to "erase" the opaque areas on the render texture. Ideally I would like the transparent areas on the sprite that I draw with to have no effect. I was wondering if an openGL blending guru was able to give me some guidance?
To clarify, the final effect that I am trying to achieve is to be able draw a sprite that includes some transparent areas to my render texture. The transparent areas of the sprite should not draw to my render texture. The opaque areas of the sprite should only draw to the render texture if they are over an opaque area on the render texture.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论