ID3DXSprite深度排序 [英] ID3DXSprite depth sorting

查看:168
本文介绍了ID3DXSprite深度排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个子图形A和B。A-不透明,Z =1。B-半透明,Z =0。绘制呼叫顺序A->B。

I have two sprites A and B. A - opaque, Z = 1. B - half-transparent, Z = 0. Draw call order A -> B.

根据 MSDN 在绘制不同深度的透明精灵时,应使用标志 D3DXSPRITE_SORT_DEPTH_BACKTOFRONT 。问题是反之亦然-仅在标志 D3DXSPRITE_SORT_DEPTH_FRONTTOBACK 下有效。

According to MSDN I should use flag D3DXSPRITE_SORT_DEPTH_BACKTOFRONT when drawing transparent sprites of varying depths. Problem is it works vice versa - only with flag D3DXSPRITE_SORT_DEPTH_FRONTTOBACK.

请说明 ID3DXSprite 中的深度排序如何工作以及Z值在哪里增长(我假设从0到1, 1距离屏幕最远。)

Please explain how depth sorting works in ID3DXSprite and where is Z value growing (I assume from 0 to 1, 1 being most remote from screen).

推荐答案

如果使用 D3DXSPRITE_SORT_DEPTH_FRONTTOBACK ,您将获得按以下顺序渲染的精灵:

If you use D3DXSPRITE_SORT_DEPTH_FRONTTOBACK, you'll get the sprites rendered in this order:

Z = 1.0
Z = 0.0

因此首先绘制了不透明的精灵,然后在其顶部渲染了半透明的精灵。如果您不希望看到两个精灵(就像在这种情况下一样),那么问题可能出在您的透明精灵的Z坐标不正确-您正在 后面绘制它。

So your opaque sprite is drawn first, then your half-transparent sprite is rendered on top of it. If you didn't expect to see both sprites (as you would with this scenario), then maybe the problem is that your transparent sprite has the wrong Z coordinate - you are drawing it behind the opaque sprite.

我目前无法找到特定参考的链接,但事实是Z值较低的子图被绘制在后面具有更高价值的精灵。这更像是窗口的Z顺序,而不是用于深度测试的上下文。

I can't at the moment find a link to a specific reference but the fact is that sprites with a lower Z value are drawn behind sprites with a higher value. This is more like the Z-order of windows rather than the context as used for depth testing. Maybe this is because sprites are inherently 2D.

来自在这里,您可以阅读以下内容:

From here, you can read this:

这篇关于ID3DXSprite深度排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆