【发布时间】: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