【问题标题】:How can i represent a number with greater precision than float using only floats and/or integers我如何仅使用浮点数和/或整数来表示比浮点​​数更精确的数字
【发布时间】:2011-12-10 03:19:11
【问题描述】:

我已经基于此编写了一个 MandelBrot 着色器:http://blogs.msdn.com/b/shawnhar/archive/2006/12/11/sixty-fractals-per-second.aspx

float4 PixelShader(float2 texCoord : TEXCOORD0) : COLOR0
{
    float2 c = (texCoord - 0.5) * Zoom * float2(1, Aspect) - Pan;
    float2 v = 0;

    for (int n = 0; n < Iterations; n++)
    {
        v = float2(v.x * v.x - v.y * v.y, v.x * v.y * 2) + c;
    }

    return (dot(v, v) > 1) ? 1 : 0;
}

我想通过使用比浮点数更精确的东西来扩展我可以放大的数量。我在网上读过一些东西,例如http://www.bealto.com/mp-mandelbrot_fp128-opencl.html,但是它很难理解并且不完整。

我使用的 GPU 不支持双精度,所以我只能使用 32 位整数和浮点数(以及长度不超过 4 的浮点数向量/数组)。

如何以比普通浮点数更精确的方式表示单个浮点数?

我需要支持的操作是 x+- 和 (>> =)

我正在使用像素着色器模型 3.0。


我查看了Q number format,但是,我遇到的问题是,如果我使用 2 个 32 位整数,我需要一个 64 位临时变量来进行乘法(和除法)。

【问题讨论】:

  • 你将不得不开发你自己的浮点格式(或者找其他已经做过的人)。这不是小事。

标签: floating-point precision hlsl fractals


【解决方案1】:

以下博客文章解决了您描述的一些问题,包括在 GLSL 中使用 2 个浮点数模拟双精度。

http://www.thasler.org/blog/?p=93

谷歌搜索“模拟双精度”应该会抛出更多链接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-26
    • 2017-11-16
    • 1970-01-01
    • 2015-01-20
    • 1970-01-01
    • 2012-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多