В ближайшее время ряд статей по CUDA


High Dynamic Range Rendering � OpenGL

������ ���� �� �� ������ ��������� ���� � ����� ����� ������������ ����������� �������� HDR (High Dynamic Range), �� � ��� ���� ��� ��� ������ ����� ����� must have.

��� �� �� ����� ���� ����� �� �������� High Dynamic Range � ��� ������������ ���� ������ � ����� ���������� ?

��� Dynamic Range ������ �������� �������� �������������� (��� ��������������) ��������. ��� ��� �������� Dynamic Range ��� ����������� �������������� �������� ������ � �������� ������� ������������ ������.

� ��������� ���� �������� ��� ��� ������� �� ������� �������� ��� Dynamic Range ��� �������� ���� (������ �� 100,000:1), ��� � ������������ ������������� �����.

����� ������� Dynamic Range ������������� ����� ������������ ������������ ����� �� ������������� � �������� ������ ������� ����� - ������� ��������� �������� ���������� ����� ������ �������� �������� �� �������� ����� ���������� �����.

�� ���� ����� ������������ ���� �������� ����� �������������� � ��� ����� � ��� ������ �����, ����������� ��� ����� ������� �������� ����������.

���� ������ � ���������� ����������� HDR-��������, ������ ��� �� ������ ����� ������ �����, �� � ����������� ������ ������� ������� �� ��, � ����� �������� ����� ������������� ����������� �� ���.

������� ���������� ����� ��� ��������, ����������� ���������� ������ ������������ ������ �������, ��������� � HDR.

� ����� ����� �������� ������ ������� ����������� ���������� ��������� exposure, ���������� ����������� �������� �������� ���������� ��� ������������� �����.

����� � ����� �������� ������ ������� � ��� ���������� bloom - ����� � ����� ����� ������� ���� ��� �� "�����������" ��� ��������� ������� ����� ���� ����������� ���������.

��� ���� ������ � ���� ����� ����� ��� ���� ������ (������???), �������� ������ ������ ���������� ������ �������� ����� - ����� ������� ������� � ������������������ ������ ��������� ��������� �����, �� ���������� �������� ����������� (�������) �������� �������, � ���������� ���� ��� ��� �� ���� ����� ����� ����.

���� �� ����� ��-���������� ������������/������������ HDR, �� �� ������ ���������� �� ���������� ���� ������ � ��������� RGB-��� - [0,1]3 � ������ ���������� ������������ ��������� � ������� � ��������� ������ (FP16 ��� FP32), ��������� ��� ������� ��������� ������� �������� � ����� ������� High Dynamic Range (���� �� �� ����� ������� �������� � ������� Dynamic Range, �� ��� �� �� ����� �� ���������� � ������������) - ����������� ������ TrueColor � 8-������ ��� ������ �������� ���������� �� ������������ ���������� �������� Dynamic Range.

� ������������� ������������� �������� � ��������� ������ �������� ��������� ������� ���� ������ ��� � 2000 ����.

����� �� ���������� ���� ������ � ��������� ��� [0,1]3 � ������������� �������� � ��������� ������ ��������� � �������� � ������� ��� ����� ������ ������, ��� � ����� ������ ����� ����� � ����� ������� ���������.

��� ���� ����� ���� ����� ��������� ���� ��������� ���� - ��� ���������� � ��������� ��� ����� (1,1,10) ������ ��������� ��� � ����� ���� (1,1,1), � �� ����� ��� � ���������������� ��� ����� ����� ������� ������ �����.

����� ����, ��� ����� ����� ��� �������������� � ��������� ����� ����� ������ ����� �����. �� ��������� ���� ��������� �����, ��� ���� ���� ��� �������� � ���������� ���� ����� ���������� � ����, �� �� �� �������� ����� �������� �����. � ���� ����� ��� ������ � ������������� ������ �� �������� �������� ��������� � ����� ������.

EN.WIKIPEDIA.ORG/WIKI/IMAGE:HL2HDRCOMPARISON.JPG

��� 1. ����� �� HalfLife 2: Lost Coast � �������������� HDR � ��� ��� �������������.

�.�. �����, ��� ����� ����������� ���������� ����� (���������, �����������, ����������� � �.�.) ������������� ������������� ������ ���� ������� ����� ����������� ���������� �����, ��� ������������� �����������.

������� ����������� ���������� HDR-���������� �� ����������� GPU ���������� ��������� ������ - ��� ����� (� ��� ������������� � ����� ��������� �� �����) ��������� � floating-point-�������� (FP16 ��� FP32).

����� ����� ������ �������� ������������� ��� ��� ���� ����� � � ���������� �� �������� ������� (�� floating-point) ����������� � ����������� �������, ������� � ���������.

����������� �������� ��������� HDR-����������� �������� ������������� bloom'�, ���������� ���������/����������� (� �������������� �������) � tone mapping, �������������� ���������� ������ � ������� ����� ������� (�.�. �� ������� ���������, ���������� � ������ ������, � ��������� ������ ������ �����).

���������� ��� ���� ���������.

������������� ������� bloom

��� ������������� bloom'� �� ��������� floating-point-����������� �������� �����, �������� ������� � ������� ���������� ���������� ��������� ����������� (����� �� �������� ��������) � ������ �� ������ ���� ������, ������� ������� ���� ��������.

���� ���������� ������ ������������ ������� ��������������� ����� �������������� �������� �������� � �������� ����� �������� ������� �� ������� ���������.

uniform sampler2D mainMap;

void main(void)
{
    vec2 dx   = vec2 ( 1.0 / 512.0, 0.0 );
    vec2 dy   = vec2 ( 0.0, 1.0 / 512.0 );
    vec4 base = texture2D ( mainMap, gl_TexCoord [0].xy ) +
                texture2D ( mainMap, gl_TexCoord [0].xy + dx ) +
                texture2D ( mainMap, gl_TexCoord [0].xy + dy ) +
                texture2D ( mainMap, gl_TexCoord [0].xy + dx + dy );

    base *= 0.25;

    if ( length ( base.rgb ) < 0.8 )
        base.rgb = vec3 ( 0.0 );

    gl_FragColor = base;
}

��������� ����� �������� ���������� � ���� �������� ��������, ������ �������� �� ������ (Gaussian blur).

� ���� ������� �������� �� ������ ��� ����� ����������� � ��� ������� - ������ �� "���������" ����������� ������ �� �����������, � ����� - ������ �� ���������. � ���������� �� �������� ������� �������� � ���������� ��������� � �������� (��� ��� ���������� ��������� � �������� ��� ������������� �������� ����� ������� ���� ��������, � ��� ������������� - �������� ������� ����, � ��� �������� � �������� ���� 10 � ����� �� �������� ������ ������������ ��������).

���� ���������� ������ ������������ ������� ��� �������� �� ����������� (�� ���� ������ ����� ������� ������ �� Python, �������� ����������� ������� ��� ������������ �������� � �������� �������� ����).

uniform	sampler2D	mainTex;

void main (void)
{
    vec2 tx  = gl_TexCoord [0].xy;
    vec2 dx  = vec2 (0.001953,0.000000);
    vec2 sdx = dx;
    vec4 sum = texture2D ( mainTex, tx ) * 0.134598;

    sum += (texture2D ( mainTex, tx + sdx ) + texture2D ( mainTex, tx - sdx ) )* 0.127325;
    sdx += dx;
    sum += (texture2D ( mainTex, tx + sdx ) + texture2D ( mainTex, tx - sdx ) )* 0.107778;
    sdx += dx;
    sum += (texture2D ( mainTex, tx + sdx ) + texture2D ( mainTex, tx - sdx ) )* 0.081638;
    sdx += dx;
    sum += (texture2D ( mainTex, tx + sdx ) + texture2D ( mainTex, tx - sdx ) )* 0.055335;
    sdx += dx;
    sum += (texture2D ( mainTex, tx + sdx ) + texture2D ( mainTex, tx - sdx ) )* 0.033562;
    sdx += dx;
    sum += (texture2D ( mainTex, tx + sdx ) + texture2D ( mainTex, tx - sdx ) )* 0.018216;
    sdx += dx;
    sum += (texture2D ( mainTex, tx + sdx ) + texture2D ( mainTex, tx - sdx ) )* 0.008847;
    sdx += dx;

    gl_FragColor = sum;
}

���������� ����� ������� �������� ����������� ��� ��� � �������� �� ������� ����� �������� �� �������� ����� �����������. ��� ����� ������ �������� ����������� ������������ � ��������� (�������� � ��������� �����). ��� ��������� ��������� ��������� ��������� ������� ��� �������� �������� ������������ ���������� ����������.

Tone mapping

����� ������� �������� ������������� ����������� ����� � ������� ����� �������� ������������� ��������� exposure, ����� ������������� ����� T.

��� ���� ������ �� �������� ��������� ������������ ���������� ��������������:

v'=1-exp(-T*v)

�������� �������������� ����� ����������� ��� ������ ����������� �������� � �������������� ��������� ����� ��������������� �������� � ������� [0,1].

��������� ������� ������� ������� �������� ��, ��� �������� ��� ��������� T ������ �����-�� ������� ����������� � ������ ������ ��� ������� �� ����� ������� �����������. ����� �� �������� ������� �������� ��� ������ ������� �������� ������ ������������� �������� � ���� �������� ����� ������� mipmip-�������, ��� ������� �� ����� �� ����� ���� �������� ������ ������� ���� �� ����� �����������.

����� �� ����� �������� ����� ����� ����� �������� ��� ��������� T.

������ ���������������� ��������� �������� ������� ��������� ������� ������� a. ����� �� ��������� ����������� ��������� ������� �������� ��������� ������� (�������� �������� �� ������������� ��������� ��������, ����������� � ������� L(x,y), ��� ��������� ������� � ���������� ��������� � ����).

tone mapping equation

����� ���� ��� �� ����������� ������� ������� ������� �������� ��������� �������, ��� ����������� ������������ ��������� ���������������, ����������� ��������:

tone mapping equation

����������� ����� ������� �������� ��, ��� �� ������ ���������� ��� �������� ��������� �������������� ������, �.�. � ����� � ������ ����� �������������� ����������� (��� ������ �� ������ ����������).

��������� ������� tone mapping'� � ���� ��������� ����� ���� ����� - ������ ����� ����� �� ����������, � �� ����� ��� ����� �������������� (�.�. �� ������� ����������).

tone mapping equation

����� ���������� ��� ������� � ���� -

tone mapping equation

����� ����� Lwhite ���������� ����������� ������� ����������� � ������ ����� ����.

��� ����� ���������, ������������� �� ������ gamedev.ru �������� ����������� ������� � ����������� �������� �������� ��������� �������, ������ ������ ��������� ������������ ������ �� �������� �������� �������� �������:

tone mapping equation

����������� ����������

��� �������� ���������� HDR-���������� ���������� ��������� floating-point-�������, ������� ����������� ���������� � ����� ��������, � ����� ����������� ���������� ���������� ������ � ��������� ��� [0,1]3.

�� ����� gamedev.ru ���� ����� ������� ������ �� ���� ��������, ������ ��� ������������� �� ������������� �-�������, � �� ����� ��� ������� ������� � ����� ������������ FBO.

���� ���������� ������� �������� ����������, ������� �� ����� � ���������� ������������.

ARB_texture_float, ATI_texture_float

��� ���������� (����� �� ����� ������������� ������ ARB-���������� ��������� ��� ���������� ���������� ������ ������� ��������) ������ ����� ���������� ������� �������, ��������������� ������������� 16-������� � 32-������� floating point ����� ��� �������� ���������.

��� ���� ��� 16-������� ����� ������� ��������� ��������� - 1 �������� ���, 5 ��� ��� ���������� � 10 ��� ��� ��������. ������ ��� 32-������� ����� ��������� ��������� � IEEE ���������� ��� 32-������� float'��.

���������� ������ ��������� ����� �������� - GL_RGBA32F_ARB, GL_RGB32F_ARB, GL_ALPHA32F_ARB, GL_INTENSITY32F_ARB, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGBA16F_ARB, GL_RGB16F_ARB, GL_ALPHA16F_ARB, GL_INTENSITY32F_ARB, GL_LUMINANCE16F_ARB � GL_LUMINANCE_ALPHA16F_ARB,

�������� ��������, ��� �������� ��������� ��������� ��� ���� ������� ����� �������� �� ������� ������� [0,1].

����� �������� ����� �������� ������� ���� ����� ��������� ����������� ��������� ���������� � �������� ��������� ������ ��������.

��� ������ ��� ������ �������� ������� ���������� ������� (bound) �������� ����� ��� ������ ���������� ��������� ����:

GLint type;

glGetTexLevelParameteriv ( GL_TEXTURE_2D, 0, GL_TEXTURE_RED_TYPE_ARB, &type );

� �������� ������������ �������� ����� ��������� GL_NONE (����� ���������� � �������� ���), GL_UNSIGNED_NORMALIZED (�������� ��� ����� ������������� ��������) � GL_FLOAT (�������� ��� floating point �����).

�������� ������ �������� ����� ����� �������������� � FBO � �������� color attachment'�, �.�. � ��� ����� ������������ ���������.

ARB_color_buffer_float

������ ���������� ��������� ��������� ����������� ������ � ��������� ��� [0,1]3. ��� ���� ���������� ����������� ����� ��� ������ �������� �� ���������� ����������� ����� ��� ����������.

������ ���������� ������ ��������� �� ��������� ��� ���������� - ���������� ������ � ��������� ��� �������������� ����� � ������ �����, ����� �������������� ��������� � floating-point �������� (��� �����). ����� ������� ��� ���������� � floating point FBO �������� ���������� ������ ��� ���������� �� ����������.

� �������� ����� �� ��������� ������ ���������� � ��������� ���.

������ ���������� ������ ������� glClampColorARB, ����������� �������� � ��������� �������������� ���������� ������.

glClampColorARB ( GLenum targte, GLenum clamp );

� �������� ��������� target ����� ��������� ��������� �������� - GL_CLAMP_VERTEX_COLOR_ARB, GL_CLAMP_FRAGMENT_COLOR_ARB � GL_CLAMP_READ_COLOR_ARB.

������ ��� �������� ��������� ����������� ������ ��� ������ � ��������� � �����������. ��������� �������� �� ���������� ������ ��� ���������� ������� glReadPixels.

�������� clamp ������ ��������� ����� � ��������� ���� �� ��������� �������� GL_FIXED_ONLY_ARB (������ ��� ���������� � �� floating-point �����), GL_TRUE � GL_FALSE.

ARB_half_float_pixel

��� ���������� ��������� ��������� ������ � �������� (� ������ ������ �� ��������) ��������������� � ������� FP16.

��� �������� � ���� ������� �������� �������������� ������ ����� ����� FP16 � ������� ������ (��������, float).

����������� ��� ������ � floating-point ���������� ��� ��������� GPU

� ��������� �� ������ ������ ����������� ��� GPU, �������������� ������ � floating-point ���������� ����������� ��� ����������� �� ������ � ����.

��� ��� ����������� (???) GPU �������� �� �������������� ������������� ������������ (mipmapping), alpha blending.

��� ����������, ����������� � ������������ ���������� �������������� ������ ��� 16-������� floating-point �������, ������ ������� � ���� GeForce6xxx.

��� ����� GeForceFX 5xxx �� �������������� ���������� � cubemap floating-point ��������, ���������� � alpha blending.

��� ����� GeForce 6xxx/7xxx ��� 32-������� floating-point ������� �������������� ���������� � cubemap ��������, , ��������� NPOT-�������.

��� 16-������� floating-point ������� ����� �������������� ��/����������� � ������������ ����������, ������������� ������������, alpha blending.

������� ������ ��� �������� HDR-�������

�������, ��� ���� �� ����� ������ GPU ������������ floating-point ��������, �� ���� �� �������� �������� ����� ����������� ������� �������� �������� � ������.

�� ������ ������ ���������� ��� ���������������� �������� ������, ����������� ������� HDR-�������� - .hdr.exr.

������ �� ���� �������� �������� ���������� ����� - �� ��� ����������� � ������� ���������� �������������� ����������� Radiance. ������ ���� ������ ����� �������� RGBE (Red, Green, Blue, Exponent).

������ ������ ����������� �������� ���������� (�� ������ ����� ��� ����� ������) - ������ ��� ������ �������� ��� ��������, �������� � ������ ������, � ��������� - ����� ��� ���� �������� ����������.

����� ����� ��� ������ ����� ������������ ����� ��� �������� RLE-������ ������ ��� ���������� ������� �����.

�������, ��� �������� �������� ������ � ���� ������� ��������, �� ���� �� ��������� ������� � �������� ���������� ������������� ��������, ������� ������������� �������.

� ����������� ���� ���������� �������� ����� �������� ���������� .hdr-������, ������ �������� ��� �������� �������� �������:

unsigned loadRgbeAsFloat ( Data * data, unsigned target, unsigned format, bool mipmap = false );
unsigned loadRgbeAsRgba  ( Data * data, unsigned target, unsigned format, bool mipmap = false );

��� ���� ������ ������� (loadRgbeAsFloat) ������ ������ floating-point-��������, � ������ ������ ������� RGBA-��������, ������ � �������� �������� ��� ���� ������� ������� RGBE ��������. ����� ������� � ���� ������ ������ ��������� ����������� ����� �� RGBE-����������� ������� �� ������. �������������� ���������� ������� �������� ������� ������� ���������� ������ ��� �������� �������� � ����������� ����� �� ���� �������������� ���������� ��� �������� (�.�. ���������� ��������� �� ��������).

������ ������ - .exr ��������� ������� ��� ���������� ��� 16- ��� 32-������� floating point ��������, ��� ������������ ������� ����� ������� �������� ������� ������� (�� �� ���� ������� �������� ������� �����).

��� ������ � ���������� � ������� .exr ����� ����� ������������ ���������� OpenEXR, ������������� ��������� Industrial Light and Magic.

������ � ��������� ��� �� ������������� VC 6.

���������� ���������� HDR-����������

���������� ������� ������ ���������� HDR-����������. ��� ����� �������� ������� �����, ����� ����� ������� �������� ������� ��������� ����� (��� ��� ��� ��� ���������� glClampColorARB)� ���������� ������� ������������� ��������� ���������.

����� ����� ���������� ��������� ���� ����� � floating-point FBO, ������ ������ ������ ���������� ������������ 16-������� float'� (����� �� ����������� ������������� floating-point ������� �������� ������� ������� ����� ������ ��� ������������ ����������� �� ��������������).

����� �� ����� FBO �������� ��������������� �������� ����� �������� ������� (�� ������� ���������), ��� ������ ���������� �������:

uniform sampler2D mainMap;

void main(void)
{
    vec2 dx   = vec2 ( 1.0 / 512.0, 0.0 );
    vec2 dy   = vec2 ( 0.0, 1.0 / 512.0 );
    vec4 base = texture2D ( mainMap, gl_TexCoord [0].xy ) +
                texture2D ( mainMap, gl_TexCoord [0].xy + dx ) +
                texture2D ( mainMap, gl_TexCoord [0].xy + dy ) +
                texture2D ( mainMap, gl_TexCoord [0].xy + dx + dy );

    base *= 0.25;

    if ( length ( base.rgb ) < 0.8 )
        base.rgb = vec3 ( 0.0 );

    gl_FragColor = base;
}

��� ����� �� ������������ �������� �������������� ���������� �������� �������� �������� (�.�. ���������� �������� �� resampling) � ��������� (���������� � ������� �����) ���� ���������� � �������� ���� ��������.

����� �� ��������� ������������� ����������� �������� (Gaussian blur). �� �������� �� ����� ������������ ��� ��� ��������� ������ ��������, �� ��������� ������ � ��� �� ������ ������� ���� ���������� ������ � ����� �����������, �� � ��������� ����� ������ ���� �� ��������� (��������������� ����������� ��������).

� ���������� ���� ���� ����� �� �������� ��������� �������� � "���������" ������ ���������.

�� �������������� ���� �� ���������� "��������" �������� � �������� � ��������� � �� ����� tone mapping, ������������� � ���� ���������� ������������ �������:

uniform sampler2D mainMap;
uniform sampler2D blurMap;
uniform float     exposure;

void main(void)
{
    vec4 base = texture2D ( mainMap, gl_TexCoord [0].xy );
    vec4 blur = texture2D ( blurMap, gl_TexCoord [0].xy );
    vec4 color = base + 5.0 * blur;

    gl_FragColor.rgb = vec3 ( 1.0 ) - exp ( -exposure * color.rgb );
    gl_FragColor.a   = 1.0;
}

���� ���������� �������� ���� �� �++, ���������� �� "��������" � ��������� �������:

void blurMap ()
{
    startOrtho ();

    buffer0.bind ();
    filterMap.bind ();
    drawQuad ( buffer.getColorBuffer () );
    filterMap.unbind ();
    buffer0.unbind ();

    buffer2.bind ();
    xBlur  .bind ();                                            // perform x-blurring first
    drawQuad ( buffer0.getColorBuffer () );
    xBlur.unbind   ();
    buffer2.unbind ();

    buffer3.bind ();
    yBlur.bind ();
    drawQuad ( buffer2.getColorBuffer () );
    yBlur.unbind ();
    buffer3.unbind ();
                                                                 // now in buffer3 we have blurred FP map
    endOrtho ();
}

void display ()
{
                                                                  // render for FP FBO
    buffer.bind ();

    reshape ( buffer.getWidth (), buffer.getHeight () );

    glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

                                                                  // draw the light
    glMatrixMode ( GL_MODELVIEW );
    glPushMatrix ();
    glClampColorARB    ( GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE );   // disable vertex color clamping
    glDisable          ( GL_TEXTURE_2D );
    glTranslatef       ( light.x, light.y, light.z );
    glColor4f          ( 30, 30, 30, 1 );
    glutSolidSphere    ( 0.1f, 10, 10 );
    glPopMatrix        ();

    glMatrixMode   ( GL_MODELVIEW );
    glPushMatrix   ();

    glRotatef    ( rot.x, 1, 0, 0 );
    glRotatef    ( rot.y, 0, 1, 0 );
    glRotatef    ( rot.z, 0, 0, 1 );

    glBindTexture ( GL_TEXTURE_2D, diffMap );

    blinnProgram.bind ();

    drawBox ( Vector3D ( -1, -1, -2 ), Vector3D ( 1.7, 1.7, 1.7 ), decalMap );

    glTranslatef ( 2.5, 2.5, 1 );
    glRotatef    ( 15*angle, 0, 1, 0 );

    glutSolidTorus ( 0.7, 1.6, 20, 20 );

    glRotatef    ( 10*angle, 0, 0, 1 );

    drawBox ( Vector3D ( -2, -2, 1 ), Vector3D ( 1.5, 1.5, 1.5 ), diffMap );

    glEnable ( GL_TEXTURE_2D );

    blinnProgram.unbind ();
    buffer.unbind       ();

    glPopMatrix ();
	
    blurMap ();

    startOrtho ();

    glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glActiveTextureARB ( GL_TEXTURE1_ARB );
    glBindTexture      ( GL_TEXTURE_2D, buffer3.getColorBuffer () );

    toneMapProgram.bind  ();
    drawQuad ( buffer.getColorBuffer () );
    toneMapProgram.unbind ();

    endOrtho ();

    glutSwapBuffers ();
}

�� ��������� ���������� ����� ������� ���������� ������ ������ ���������.

HDR image

HDR image

HDR image

� ��������� ������ � floating-point ���������� ����� ��� ������ GPU ��������� �����������, ������� � ��������� ������� ����� ������������� ��������� ������� HDR � � �������������� ������� �������.

������ ������� ���������� �������� �������� ��������, ������������ ��� ��������� HDR-���������� ��� ������ �������� ������������ - �������� ��������� �������, ������������ ������ ��������� (exposure). ���� ��� ���������� �������� �� ����� � ����� ����� �� ������ ������� (�� HDR) ����������� ������������ (������� �����������) �������� HDR-�����������.

���� ������������ ������, ��� ���������� ���������� ������ ���������� � ���������� RGB-���� - ��� ������ � ��������, � ��� ������� ����������� ����������� �������� � �������������� floating-point �����. ������ ��� ���������� ����������� ���������� � ��������/���������� ���������� ���������� � ��������� �������� ������������� (������ ��� ���������� ��������� ����� 8 ���).

� ���������� �������� ������������� �������� �������� ������, � ��� �������� � ���������� ������ �����. ������� ���� ��� ��������� ����� �������� ����� � ��������� ������������ (�������), ���� �� ��� ���� �� ��������� ���������.

��� ����� �������� ���� ������� ������������ � ���� ���������� (� �� ����� ������� �� [0,1]), � �� ������ ���������� ������� ���� �������� �� 8. � ���������� � ��� ��� �� ��������� ��� �����������, ��������������� ������ ��������� ��������. ���������� �������� �� ������� ������ ����� ��������� �������� ����� ��������� �� [0,8] (������ � ������� ���������).

�������, ��� ����� �� ������ �������� �� ������ ����� ��������, �������� �� 8, �� � �������� ������� ������ �����. ����� �� ��������� �������� �� ������� ����������� � ����������� �� ���������� �������, ������� �� 8.

�������, ��� ��� ���� ��������� ����������� � HDR, ������ ����� ��������� ����������� ���� ��� ������ � ������������� - ���� � ���, ��� ������� ����� �������� ��� ������������� � ���� �����, ������ ������ ������. � ���� �������������� ������� �� 8 ������ ���������� ��� ��������.

� �������� �������� ������ � ���� ����� ������ ������ ��������� �� 8 � ����� �����, ��������, ��������, �� 2 ��� ������ �������� � ���������. ��� �������� ��������� ��������� ����������� ������ ������ � ������ (��������� �������� �� ����� ���� ��� ��� ������ ������ ������ ����� ��� ������������).

���� ��� ����� ������� ��� ����� �������� ������������� ������������ � �������� ������������, ������� ����� ����� �� ���� ����� ������ � ��������.

���������� ����� ������ ��������� tone mapping'�

���� ���������� ����������� ������� ��� ����������������� ��������� tone mapping'�. �������� ��������, ��� ��� ��������� �������� �������� �� ���� �������� ���������� ������ �������� �� ���, ����� ������� �������� ��� mipmap-������ (���� ������������� ������������ �������������� � �������� ���������, �� �� ������� ��� ��� � ����� ��������� ������� �������� ��� ���� ��������).

//
// Simple Reinhard tone mapping (log/exp)
//

uniform sampler2D mainMap;
uniform sampler2D blurMap;

uniform float grayLevel;

void main(void)
{
    vec4  base   = texture2D ( mainMap, gl_TexCoord [0].xy );
    vec4  blur   = texture2D ( blurMap, gl_TexCoord [0].xy );
    float avgLum = exp ( texture2D ( blurMap, gl_TexCoord [0].xy, 12 ).a );

    base = base * (grayLevel / avgLum);

    vec4 color = base + 5.0 * blur;

    gl_FragColor = vec4 ( color.rgb, 1.0 );
}

// 
// Simple tone mapping using L/(1+L) mapping
//

uniform sampler2D mainMap;
uniform sampler2D blurMap;


void main(void)
{
    const vec3  luminance = vec3 ( 0.3, 0.59, 0.11 );
    vec4        base      = texture2D ( mainMap, gl_TexCoord [0].xy );
    vec4        blur      = texture2D ( blurMap, gl_TexCoord [0].xy );
    float       l         = dot ( luminance, base );
    float       scale     = l / ( 1.0 + l );

    vec4 color = base * scale + 5.0 * blur;

    gl_FragColor = vec4 ( color.rgb, 1.0 );
}

//
// Composite log/exp and L/(1+L)
//

uniform sampler2D mainMap;
uniform sampler2D blurMap;

uniform float lWhite;


void main(void)
{
    vec4  base   = texture2D ( mainMap, gl_TexCoord [0].xy );
    vec4  blur   = texture2D ( blurMap, gl_TexCoord [0].xy );
    float l      = dot ( vec3 ( 0.3, 0.59, 0.11 ), base );
    float scale  = l / ( 1.0 + l ) * (1.0 + l / (lWhite*lWhite));
	
    vec4 color = base * scale + 5.0 * blur;

    gl_FragColor.rgb = color.rgb;
    gl_FragColor.a   = 1.0;
}

//
// Using average of squared L
//

uniform sampler2D mainMap;
uniform sampler2D blurMap;

uniform float grayLevel;

void main(void)
{
    vec4  base   = texture2D ( mainMap, gl_TexCoord [0].xy );
    vec4  blur   = texture2D ( blurMap, gl_TexCoord [0].xy );
    float avgLum = sqrt ( 0.0001 + texture2D ( blurMap, gl_TexCoord [0].xy, 12 ).a );

    base = base * (grayLevel / avgLum);
    base = base / ( vec4 ( 1.0 ) + base );

    vec4 color = base + 5.0 * blur;

    gl_FragColor = vec4 ( color.rgb, 1.0 );
}

�� ���� ������ ����� ������� ���� �������� ��� � ���� ������. ����� �������� ��� ���������� ����������������� ������ ��� M$ Windows, LinuxMac OS X.