是否可以在 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 (将#修改为@)