OpenGl 混合
我想混合两个矩形,但我只想绘制混合区域(矩形相交的区域),该怎么做
i want to blend two rects, but i want to draw only blended area (area where rects are intersecting), How to do it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您不想计算交集,您可以使用模板缓冲区来实现。在这里阅读:
http://bluevoid.com/opengl/sig00/advanced00/notes/node118.html
您可以在模板缓冲区上以增量绘制两个矩形 和 ,然后仅屏蔽具有值 > 的像素。 2,即绘制2个或更多矩形的像素。
If you don't want to compute the intersection you can probably use the stencil buffer to achieve that. read about it here:
http://bluevoid.com/opengl/sig00/advanced00/notes/node118.html
You can draw the two rects and with increment on the stencil buffer and then mask only the pixels that have value > 2, i.e. the pixels where 2 or more rects were drawn.
两个凸矩形的交集始终是一个矩形。那么为什么不只计算交集并只绘制交集呢?
The intersection of two convex rects is always a rect. so why not just compute the intersection and draw only the that?
但是您应该自己设置混合函数的行为。
在着色器中我设置了 Alpha 通道。您可以看到结果:
混合帖子。
android项目的源码
But you should set behavior of your blend function yourown.
And in the shader I set alpha channel. You can see the result:
blending post.
the source of android project