[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Openexr-devel] 3D Lut in software
From: |
Jim Atkinson |
Subject: |
Re: [Openexr-devel] 3D Lut in software |
Date: |
Mon, 23 Feb 2015 09:34:32 -0800 |
On Feb 22, 2015, at 3:35 PM, Gonzalo Garramuno <address@hidden> wrote:
> My application uses a 3D OpenGL Texture in log space for its table lookups,
> with code borrowed from playexr. However, now I need to do the 3d lut lookup
> in software so I can display the color picker correctly showing the
> transformed colors.
> I ask here for some help in seeing what I am doing wrong. Sorry for the long
> code.
...
> And here's my software evaluation routine which tries to mimic the shader
> code:
>
> void GLLut3d::evaluate( const Imath::V3f& rgb, Imath::V3f& out ) const
> {
> using namespace Imath;
>
> V3f pMin( lutMin, lutMin, lutMin );
> V3f pMax( lutMax, lutMax, lutMax );
> V3i size( _lutN, _lutN, _lutN );
>
> out.x = lutT + lutM * log( Imath::clamp( rgb.x, lutMin, lutMax ) );
> out.y = lutT + lutM * log( Imath::clamp( rgb.y, lutMin, lutMax ) );
> out.z = lutT + lutM * log( Imath::clamp( rgb.z, lutMin, lutMax ) );
>
> out = Ctl::lookup3D( (V3f*)&lut[0], size, pMin, pMax, out );
> out.x = exp( out.x );
> out.y = exp( out.y );
> out.z = exp( out.z );
> }
>
>
> The problem seems to be the Ctl::lookup3D function, which returns all
> negative numbers no matter what.
They should be negative numbers:
0.1 == exp(-2.30259)
0.2 == exp(-1.60944)
0.3 == exp(-1.20397)
0.4 == exp(-0.91629)
0.5 == exp(-0.69315)
0.6 == exp(-0.51083)
0.7 == exp(-0.35667)
0.8 == exp(-0.22314)
0.9 == exp(-0.10536)
1.0 == exp( 0.00000)
Unless you expect out values greater than 1.0, the values feeding into exp()
will all be negative.
- Jim