Quick 8-bit pseudo HDR Http://bbs.gameres.com/showthread.asp? Threadid = 23298
I read the document from teacher Hugo and tried it.
Write a fragment shader, written in shaderdesigner.
Fakehdr. Frag
// Http://freespace.virgin.net/hugo.elias/graphics/x_posure.htm
// Teacher Hugo pointed out that the exposure is determined by the light in the camera.
// After an image is rendered, it should be saved in the float16 format.
// However, if an rendertarget is not in float16 format
// The average surrounding color is used as the factor to determine the exposure,
// The following shader code should be said to be very cost-effective. But the effect looks okay.
Uniform sampler2d texture;
Const float blurfactor = 12.5; // blur level, that is, to retrieve pixels from multiple distances
Const float expfactor = 0.8; // exposure
Const float cdelp = 0.0009765625; // float size of a pixel. The texture I use is 1024. Calculate it by yourself.
Const float sharpness = 0.8; // read the code ....
Vec4 xposure (vec4 Cl, float E)
{
Return (exp (expfactor)-exp (expfactor-E) * Cl;
}
Void main ()
{
Float delp = blurfactor * cdelp;
Vec4 texcolor = texture2d (texture, vec2 (gl_texcoord [0]. S, gl_texcoord [0]. t ));
// Make the color of the current position and the surrounding blur. When the impression is calculated and the final color is combined, the weight is different,
// The final color is .....
Vec4 color = texcolor * 2.0/22.0;
Color + = texture2d (texture, vec2 (gl_texcoord [0]. S + delp, gl_texcoord [0]. t + delp) * 5.0/22.0;
Color + = texture2d (texture, vec2 (gl_texcoord [0]. S + delp, gl_texcoord [0]. T-delp) * 5.0/22.0;
Color + = texture2d (texture, vec2 (gl_texcoord [0]. S-delp, gl_texcoord [0]. T-delp) * 5.0/22.0;
Color + = texture2d (texture, vec2 (gl_texcoord [0]. S-delp, gl_texcoord [0]. t + delp) * 5.0/22.0;
Float E = color. R * 0.3 + color. g * 0.59 + color. B * 11;
// Calculates the brightness,
Gl_fragcolor = xposure (texcolor * sharpness + color * (1-sharpness), e );
}
I don't know how to map images on the blog. For details, see
Http://bbs.chinagamedev.net/showthread.php? T = 9679