[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Openexr-devel] luts
From: |
Lutz Latta |
Subject: |
Re: [Openexr-devel] luts |
Date: |
Tue, 17 Feb 2004 23:48:00 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 |
Ken McGaugh wrote:
I'm now need to use luts in my fragment shader, and I
think this pack_2half/unpack_4ubyte trick is very cool. But
my fragment shaders are arbfp1 instead of fp30 (for portability).
Is there anyway to do the same thing using arbfp1?
The trick is just a speed up of the way you would do it normally with integer
arithmetic on the CPU, using a modulus and integer division. Since current GPUs
don't have such integer arithmetic natively (although Cg can emulate it), the
fastest way is to use the floating point functions fmod and floor. I've used
the following in a different context:
float2 p = float2(fmod(i, 256), floor(i / 256) + 0.5);
Note that the "+ 0.5" was to get away from the nearest neighbor sampling
boundaries. Check whether it is needed in your context, or whether you need similar
offsets somewhere else in the computation.
Cheers,
Lutz