Bloom: Weight the different sized contribution.

This commit is contained in:
Vincent Lejeune 2014-04-14 02:45:15 +02:00
parent 59df5a90bc
commit ba27eb42ef
4 changed files with 8 additions and 2 deletions

View File

@ -16,7 +16,7 @@ void main()
vec3 col = texture(tex, uv).xyz; vec3 col = texture(tex, uv).xyz;
float luma = getCIEYxy(col).x; float luma = getCIEYxy(col).x;
col *= smoothstep(1., 100., luma); col *= smoothstep(1., 10., luma);
FragColor = vec4(col, 1.0); FragColor = vec4(col, 1.0);
} }

View File

@ -67,6 +67,7 @@ PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
PFNGLBLENDCOLORPROC glBlendColor;
#endif #endif
static bool is_gl_init = false; static bool is_gl_init = false;
@ -213,6 +214,7 @@ void initGL()
glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBlitFramebuffer"); glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBlitFramebuffer");
glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformBlockIndex"); glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformBlockIndex");
glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)IRR_OGL_LOAD_EXTENSION("glUniformBlockBinding"); glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)IRR_OGL_LOAD_EXTENSION("glUniformBlockBinding");
glBlendColor = (PFNGLBLENDCOLORPROC)IRR_OGL_LOAD_EXTENSION("glBlendColor");
#ifdef DEBUG #ifdef DEBUG
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB"); glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
#endif #endif

View File

@ -84,6 +84,7 @@ extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
extern PFNGLBLENDCOLORPROC glBlendColor;
#ifdef DEBUG #ifdef DEBUG
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
#endif #endif

View File

@ -658,10 +658,13 @@ void PostProcessing::render()
// Additively blend on top of tmp1 // Additively blend on top of tmp1
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo); glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_CONSTANT_COLOR, GL_ONE);
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
glBlendColor(.125, .125, .125, .125);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_128)); renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_128));
glBlendColor(.25, .25, .25, .25);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_256)); renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_256));
glBlendColor(.5, .5, .5, .5);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_512)); renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
glDisable(GL_BLEND); glDisable(GL_BLEND);
} // end if bloom } // end if bloom