我可以在 FX Composer 中控制绘制顺序吗?
我正在使用 Nvidia FX Composer 编写半透明 CgFX 着色器。一切都很好,预计在我的渲染视图中,场景后面的对象会绘制在我的着色对象之上。
这是我的技术:
technique Main { pass p0 { DepthTestEnable = true; DepthMask = false; CullFaceEnable = false; BlendEnable = true; BlendFunc = int2(SrcAlpha, OneMinusSrcAlpha); DepthFunc = LEqual; VertexProgram = compile vp40 std_VS(); FragmentProgram = compile gp4fp std_PS(); } }
如果我打开 DepthMask,那么后面的对象就会被完全遮盖,这违背了透明度的目的。看起来对象没有被从后到前绘制。有没有办法确认这一点,我可以控制 FX Composer 的渲染器将项目绘制到屏幕上的顺序吗?
I'm using Nvidia FX Composer to write a semi-transparent CgFX shader. Everything is fine, expect that in my render view, objects in the back of the scene are getting drawn on top of my shaded object.
here's my technique:
technique Main { pass p0 { DepthTestEnable = true; DepthMask = false; CullFaceEnable = false; BlendEnable = true; BlendFunc = int2(SrcAlpha, OneMinusSrcAlpha); DepthFunc = LEqual; VertexProgram = compile vp40 std_VS(); FragmentProgram = compile gp4fp std_PS(); } }
If I turn on DepthMask, then objects in the back get masked out entirely, which defeats the purpose of transparency. It seems like the objects are not being drawn back-to-front. Is there a way to confirm that, and can I control the order in which FX Composer's renderer draws items to the screen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不能在着色器内完成,您需要更改使用它的应用程序。一般规则是首先绘制所有实体对象,然后在顶部绘制所有透明对象。
一旦绘制了透明对象,就无法渲染其后面的对象并期望它们进行混合。 OpenGL 可以渲染它,也可以不渲染它(由于 z 缓冲区剔除)。
从后向前绘制对象通常成本太高,无法实时完成,因为它需要每秒重新排序整个场景 60 次!
This can't be done inside a shader, you need to change the application using it. The general rule is to draw all solid objects first, and then all transparent objects over top.
Once you've drawn a transparent object, you can't render objects behind it and expect them to be blended. OpenGL can either render it, or not render it (due to z-buffer culling).
Drawing objects back to front is usually too expensive to do in real time, as it would require re-sorting the whole scene 60 times a second!