Histogram and Histogram Equ from LogLuv(LogL)

Started by
-1 comments, last by directNoob 14 years, 4 months ago
Hi. Currently Im totally stucked. I try to do HDR rendering with the LogLuv approach. All this is done using OpenGL and GLSL. (I use multiple knowlege from the Inet. I post it at the end if anyone is interested.) 1. The scene is rendered into an RGBA8 render target with LogLuv encoding. 2. A histogram is created via vertex shader scattering. 3. A Summed Area Table(SAT) of the histogram is created resulting in the CDF of the input image. 4. The histogram and the SAT, both in a texture are available to the tone mapping pixel shader. Here is a image of the histogram(top) and the SAT(bottom): Free Image Hosting at www.ImageShack.us The green bar(#3) in the histogram(top) is the center, this is where log2(L=1)=0 values are mapped to. This means, L<1(also means: -64<=LogL<0) value are at the left side and L>1(also means: 0<LogL<=64) are mapped to the right of the green bar. #1 are very dark values, i.e. near black. #2 are a bit dark values. They are < 1.0. All this is done per frame on the GPU. This histogram has 2000 bins and the input image is a rendered scene(which is very dark) and has res 800x600. The histogram is created with blending which accumulates 1/num_pixels at each scattered fragment. This means, if the image is pure white, the histogram has a single white bar at the most right bin. The slots/bins are selected in the vertex shader like so:

void main()
{
	//
	// Get the scenes logLuv value at this pixel(tex coord!).
	// Note that the pixel value is fetched in the vertex shader.
	// Encoded: 
	// x: Ue
	// y: Ve
	// z: High LogLe
	// w: Low LogLe
	// 
	// See www.realtimecollisiondetection.net for LogLuv HDR (!!!)
	//
	vec4 logLuv = texture2D( tex_scene, gl_MultiTexCoord0.xy ) ;
	
	//
	// decode the LogLe( lograrithmic luminance ) 
	// logLe in [0,255]
	//
	float logLe = logLuv.z * 254.0 + logLuv.w ;
	
	// 
	// Scale to range in [-64,64]
	//
	logLe = (logLe - 127.0)/2.0f ;
	
	
	//
	// Scatter the logLe to the propper histogram bin.
	// The w component is set to 64, this is the max. logl value.
	//
	// This means, -64 is scattered to -1, where
	// 64 is scattered to +1.
	// After this, going into projection space.
	// The screen space trafo then, transforms into propper histogram bin.
	//
	gl_Position = vec4( logLe,  0.0, 0.0, 64.0 ) ;
}




Now, I dont want to blow up the post. My first question is, is the scattering done correctly? I mean, can I do it like this or do I have to do some kind of scaling before the scattering? But the histogram looks plausible. The scene has two very dark lights which can be seen in the histogram. Please remember, LogL values are accumulated and stored in the histogram. Thanks Alex

This topic is closed to new replies.

Advertisement