且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将负值混合到framebuffer 0 opengl中

更新时间:2023-01-27 14:05:00

是否有一种方法可以禁止将片段着色器输出限制为[0,1]?

Is there a way to disable clamping of fragment shader outputs to [0, 1]?

让我引用17.3.6 Blending 部分. rel ="nofollow noreferrer"> OpenGL 4.6核心配置文件规范(重点是我):

Let me quote from section 17.3.6 Blending of the OpenGL 4.6 Core Profile Specification (emphasis mine):

如果颜色缓冲区是定点的,则的组成部分以及目标值和混合因子分别将各自的无符号限制为[0,1]或[-1,1]在评估混合方程之前,先对归一化或有符号归一化的颜色缓冲区进行归一化处理. 如果颜色缓冲区为浮点,则不会发生钳位. 四个值将发送到下一个操作.

If the color buffer is fixed-point, the components of the source and destination values and blend factors are each clamped to [0, 1] or [−1, 1] respectively for an unsigned normalized or signed normalized color buffer prior to evaluating the blend equation. If the color buffer is floating-point, no clamping occurs. The resulting four values are sent to the next operation.

因此,您可以使用*16F*32F格式之一来消除钳位.

So you can use one of the *16F or *32F formats to get rid of the clamping.

我知道没有一种方法可以渲染为带符号的归一化纹理,因此可能存在OpenGL限制来阻止这种情况.

I know that there is not a way to render to a signed normalized texture, so maybe there is an OpenGL limitation that prevents this.

该规范将各种_SNORM标记为 color-renderable .但是,与此同时,规范并未将这些格式标记为渲染目标要支持的必需,因此实现可以允许您使用这种格式,但是他们不必这样做,所以是的,您不能以任何方式依赖它……

The spec marks the various _SNORM as color-renderable. However, at the same time, the spec does not mark these formats as required to be supported for a render target, so implementations can allow you to use such a format, but they don't have to, so yes, you can't relie on that in any way...