微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

是否可以在 OpenGL 或 DirectX 中创建一个自定义混合模式来充当“数据castcade”?我希望存储深度信息

如何解决是否可以在 OpenGL 或 DirectX 中创建一个自定义混合模式来充当“数据castcade”?我希望存储深度信息

我希望在游戏渲染过程中尽可能多地保存深度信息,以便可以使用额外数据完成更高级的不同屏幕空间效果。这种混合模式将允许在典型渲染期间最多保存四个深度通道,同时保持深度排序。

混合模式的工作方式类似于以下 sudo 代码

Cascade Blend mode:

 R channel
 If there is something in the green channel and nothing in the red channel,draw to the channel.
 
 G channel:
 If there is something in the blue channel and nothing in the green channel,draw to the channel.

 B channel:
 If there is something in the alpha channel and nothing in the blue channel,draw to the channel.
 
 A channel
 If there is nothing in the alpha channel,draw to the channel.

这的实现可能看起来像这样:

 dest_r = src_r * (ceil(dest_g) - ceil(dest_r));
 dest_g = src_g * (ceil(dest_b) - ceil(dest_g));
 dest_b = src_b * (ceil(dest_a) - ceil(dest_b));
 dest_a = src_a * (1.0 - ceil(dest_a));

由于混合模式不能像片段着色器那样用代码直接修改,我很好奇是否可以在现有技术的混合模式中实现这样的事情。执行多着色器传递是不现实的,因为可能会渲染数千个对象。每次渲染单个对象后,都需要复制当前帧缓冲区并将其传递回着色器。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。