How can i represent a number with greater precision than float using only floats and/or integers

StackOverflow https://stackoverflow.com/questions/7808381

문제

I've written a MandelBrot shader based on this: 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;
}

I'd like to extend the amount i can zoom by, by using something with more precision than a float. I've read a few things online such as http://www.bealto.com/mp-mandelbrot_fp128-opencl.html however, it's pretty hard to understand and is incomplete.

The GPU i'm using doesn't support double, so i'm stuck with 32-bit ints and floats (and vectors/arrays of floats up to 4 in length).

How can i represent a single floating point number in a more precise way than a normal float allows?

Operations i need to support are x, +, - and (> or >=)

I'm using pixel shader model 3.0.


I have had a look at the Q number format, however, the problem i have is that if i use 2 32bit ints i need a 64bit temporary variable for multiplication (and division).

도움이 되었습니까?

해결책

The following blog post tackles some of the issues you describe, including emulating double precision using 2 floats in GLSL.

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

Googling "emulated double precision" should throw up a few more links.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top