In the process of converting my lazy webgl rendering, I use high dynamic range. I read a lot about the subject from various sources on the Internet, and I have several questions that I hope can be clarified. Most of the reading I have done covers HDR image rendering, but my questions are about how rendering can change to support HDR.
As I understand it, HDR is essentially trying to capture higher light ranges so that we can see the details in both brightly lit and dark scenes. Usually in games we use intensity 1 to represent white light and 0 black. But in the HDR / real world, ranges are much more diverse. That is, the sun in the engine can be 10,000 times brighter than bulb 10.
To deal with these larger ranges, you must convert the renderer to use floating point rendering goals (or, ideally, half-float because they use less memory) for your light passages.
My first question is about lighting. Besides the goals of floating point rendering, does this just mean that if I used to have light representing the sun, which was intense 1, it could / should now display as 10000? I.e.
float spec = calcSpec();
vec4 diff = texture2D( sampler, uv );
vec4 color = diff * max(0.0, dot( N, L )) * lightIntensity + spec; //Where lightIntensity is now 10000?
return color;
Are there any other fundamental changes to the lighting system (other than floating textures and higher ranges)?
, float render, ( , ). - , . , . , .
, -, HDR- . , , - Uncharted 2:
const float A = 0.15;
const float B = 0.50;
const float C = 0.10;
const float D = 0.20;
const float E = 0.02;
const float F = 0.30;
const float W = 11.2;
vec3 Uncharted2Tonemap(vec3 x)
{
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}
...
vec4 texColor = texture2D(lightSample, texCoord );
texColor *= 16;
float ExposureBias = 2.0;
vec3 curr = Uncharted2Tonemap( ExposureBias * texColor.xyz );
vec3 whiteScale = 1.0 / Uncharted2Tonemap(W);
vec3 color = curr * whiteScale;
color.x = pow( color.x, 1.0 /2.2 );
color.y = pow( color.y, 1.0 /2.2 );
color.z = pow( color.z, 1.0 /2.2 );
return vec4( color, 1.0 );
. , ? , , , HDR - ? , , , ? , ?
- , , - . , -, . , , , . , :
vec4 diff = pow( texture2D( sampler, uv), 2.2 );
:
pow(color,1/2.2);
, . , , , .
-. , ? , , ?
, . -, ?