diff --git a/data/shaders/tonemap.frag b/data/shaders/tonemap.frag index d859bd492..f7b2d54b7 100644 --- a/data/shaders/tonemap.frag +++ b/data/shaders/tonemap.frag @@ -33,8 +33,6 @@ void main() // Uncharted2 tonemap with Auria's custom coefficients vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06); - // Protect us from negative coefficient just in case... - perChannel = max(perChannel, vec4(0.)); perChannel = pow(perChannel, vec4(2.2)); vec2 inside = uv - 0.5; diff --git a/data/shaders/utils/getLightFactor.frag b/data/shaders/utils/getLightFactor.frag index c17a3ca8b..9bf4cdf58 100644 --- a/data/shaders/utils/getLightFactor.frag +++ b/data/shaders/utils/getLightFactor.frag @@ -14,6 +14,6 @@ vec3 getLightFactor(float specMapValue) vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz; vec3 SpecularComponent = texture(SpecularMap, tc).xyz; float ao = texture(SSAO, tc).x; - vec3 tmp = DiffuseComponent + SpecularComponent * max(specMapValue, 0.); + vec3 tmp = DiffuseComponent + SpecularComponent * specMapValue; return tmp * ao; } \ No newline at end of file diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp index 00353a264..189f78aa3 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp @@ -499,6 +499,36 @@ void IrrPrintXGrabError(int grabResult, const c8 * grabCommand ) static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig) { GLXContext Context; + int compat43ctxdebug[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 4, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + None + }; + int compat43ctx[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 4, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + None + }; + int core43ctxdebug[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 4, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + None + }; + int core43ctx[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 4, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + None + }; int compat33ctxdebug[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, @@ -553,7 +583,19 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig) PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = 0; glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" ); + + // create compat 4.3 context (for proprietary drivers) + Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? compat43ctxdebug : compat43ctx); + if (!XErrorSignaled) + return Context; + XErrorSignaled = false; + // create core 4.3 context (for mesa) + Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? core43ctxdebug : core43ctx); + if (!XErrorSignaled) + return Context; + + XErrorSignaled = false; // create compat 3.3 context (for proprietary drivers) Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? compat33ctxdebug : compat33ctx); if (!XErrorSignaled) diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 42559bfda..90c7c85ba 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -335,6 +335,8 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &auxiliary) { assert(in_fbo.getWidth() == auxiliary.getWidth() && in_fbo.getHeight() == auxiliary.getHeight()); + if (irr_driver->hasARBComputeShaders()) + glMemoryBarrier(GL_FRAMEBUFFER_BARRIER_BIT); float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight(); { if (!irr_driver->hasARBComputeShaders()) @@ -345,8 +347,10 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a } else { - glUseProgram(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->Program); + glBindSampler(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_source, 0); + glBindSampler(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_depth, 0); + glBindSampler(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_dest, 0); glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_source, in_fbo.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F); glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F); glBindImageTexture(FullScreenShader::ComputeGaussian17TapHShader::getInstance()->TU_dest, auxiliary.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F); @@ -354,24 +358,35 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1); } } + if (irr_driver->hasARBComputeShaders()) + glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); { +#ifdef WIN32 if (!irr_driver->hasARBComputeShaders()) +#endif { in_fbo.Bind(); FullScreenShader::Gaussian17TapVShader::getInstance()->SetTextureUnits(createVector(auxiliary.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0])); DrawFullScreenEffect(core::vector2df(inv_width, inv_height)); } +#ifdef WIN32 else { glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->Program); + glBindSampler(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_source, 0); + glBindSampler(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_depth, 0); + glBindSampler(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, 0); glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_source, auxiliary.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F); glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F); glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F); FullScreenShader::ComputeGaussian17TapVShader::getInstance()->setUniforms(); glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1); } +#endif } + if (irr_driver->hasARBComputeShaders()) + glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT); } void PostProcessing::renderPassThrough(GLuint tex)