Add a way to run STK without srgb framebuffer

This commit is contained in:
Deve 2017-10-09 21:18:15 +02:00
parent 0453809915
commit ae4e302741
21 changed files with 114 additions and 54 deletions

View File

@ -4,17 +4,17 @@
<card is="Intel(R) HD Graphics" os="windows" version="<9.0" disable="HighDefinitionTextures"/> <card is="Intel(R) HD Graphics" os="windows" version="<9.0" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="UniformBufferObject"/> <card is="Intel(R) HD Graphics 2000" os="windows" disable="UniformBufferObject"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="AdvancedPipeline"/> <card is="Intel(R) HD Graphics 2000" os="windows" disable="AdvancedPipeline"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="FramebufferSRGBWorking"/> <card is="Intel(R) HD Graphics 2000" os="windows" disable="FramebufferSRGBWorkaround1"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="HighDefinitionTextures"/> <card is="Intel(R) HD Graphics 2000" os="windows" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="UniformBufferObject"/> <card is="Intel(R) HD Graphics 3000" os="windows" disable="UniformBufferObject"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="AdvancedPipeline"/> <card is="Intel(R) HD Graphics 3000" os="windows" disable="AdvancedPipeline"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="FramebufferSRGBWorking"/> <card is="Intel(R) HD Graphics 3000" os="windows" disable="FramebufferSRGBWorkaround1"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="HighDefinitionTextures"/> <card is="Intel(R) HD Graphics 3000" os="windows" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 4600" os="windows" disable="ComputeShader"/> <card is="Intel(R) HD Graphics 4600" os="windows" disable="ComputeShader"/>
<card contains="Intel" os="osx" disable="GI"/> <card contains="Intel" os="osx" disable="GI"/>
<card contains="Intel" os="linux" version="<11.2" disable="ComputeShader"/> <card contains="Intel" os="linux" version="<11.2" disable="ComputeShader"/>
<card contains="Intel" os="linux" version="<11.2" disable="GeometryShader"/> <card contains="Intel" os="linux" version="<11.2" disable="GeometryShader"/>
<card contains="Intel" os="linux" disable="FramebufferSRGBCapable"/> <card contains="Intel" os="linux" disable="FramebufferSRGBWorkaround2"/>
<card contains="Intel" os="linux" version="<11.2" disable="TextureCompressionS3TC"/> <card contains="Intel" os="linux" version="<11.2" disable="TextureCompressionS3TC"/>
<card contains="Intel" os="windows" disable="TextureCompressionS3TC"/> <card contains="Intel" os="windows" disable="TextureCompressionS3TC"/>
<card contains="Intel" os="osx" disable="TextureCompressionS3TC"/> <card contains="Intel" os="osx" disable="TextureCompressionS3TC"/>

View File

@ -44,7 +44,11 @@ void main(void)
col = vec4(new_color.r, new_color.g, new_color.b, col.a); col = vec4(new_color.r, new_color.g, new_color.b, col.a);
} }
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2)); col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.); FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.);
} }

View File

@ -20,7 +20,13 @@ void main(void)
#else #else
vec4 col = texture(tex, uv); vec4 col = texture(tex, uv);
#endif #endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a < 0.5) discard; if (col.a < 0.5) discard;
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
FragColor = vec4(col.xyz, 1.); FragColor = vec4(col.xyz, 1.);
} }

View File

@ -32,8 +32,13 @@ void main(void)
float emitmap = texture(SpecMap, uv).b; float emitmap = texture(SpecMap, uv).b;
float mask = texture(colorization_mask, uv).a; float mask = texture(colorization_mask, uv).a;
#endif #endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard; if (col.a * color.a < 0.5) discard;
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
if (color_change.x > 0.0) if (color_change.x > 0.0)
{ {

View File

@ -40,11 +40,12 @@ void main(void)
col = vec4(new_color.r, new_color.g, new_color.b, col.a); col = vec4(new_color.r, new_color.g, new_color.b, col.a);
} }
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled) #if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= color.xyz;
#else
col.xyz *= pow(color.xyz, vec3(2.2)); col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif #endif
float specmap = texture(SpecMap, uv).g; float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b; float emitmap = texture(SpecMap, uv).b;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.); FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);

View File

@ -18,10 +18,10 @@ void main(void)
#endif #endif
if (col.a < 0.5) discard; if (col.a < 0.5) discard;
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled) #if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= color.xyz;
#else
col.xyz *= pow(color.xyz, vec3(2.2)); col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif #endif
FragColor = vec4(col.xyz, 1.); FragColor = vec4(col.xyz, 1.);

View File

@ -27,10 +27,10 @@ void main(void)
#endif #endif
if (col.a * color.a < 0.5) discard; if (col.a * color.a < 0.5) discard;
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled) #if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= color.xyz;
#else
col.xyz *= pow(color.xyz, vec3(2.2)); col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif #endif
float mask = texture(colorization_mask, uv).a; float mask = texture(colorization_mask, uv).a;

View File

@ -13,7 +13,7 @@ void main()
// Uncharted2 tonemap with Auria's custom coefficients // Uncharted2 tonemap with Auria's custom coefficients
vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06); vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06);
#if !(defined(GL_ES) && defined(Advanced_Lighting_Enabled)) #if !(!defined(sRGB_Framebuffer_Usable) && defined(Advanced_Lighting_Enabled))
perChannel = pow(perChannel, vec4(2.2)); perChannel = pow(perChannel, vec4(2.2));
#endif #endif

View File

@ -19,7 +19,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
vec3 emitCol = diffuseMatColor.xyz * diffuseMatColor.xyz * diffuseMatColor.xyz * 15.; vec3 emitCol = diffuseMatColor.xyz * diffuseMatColor.xyz * diffuseMatColor.xyz * 15.;
return tmp * ao + (emitMapValue * emitCol); return tmp * ao + (emitMapValue * emitCol);
#else #else
#if defined(GL_ES) #if !defined(sRGB_Framebuffer_Usable)
return diffuseMatColor * 0.73; // 0.5 ^ (1. / 2.2) return diffuseMatColor * 0.73; // 0.5 ^ (1. / 2.2)
#else #else
return diffuseMatColor * 0.5; return diffuseMatColor * 0.5;

View File

@ -53,6 +53,7 @@ void CentralVideoSettings::init()
hasTextureFilterAnisotropic = false; hasTextureFilterAnisotropic = false;
hasTextureSwizzle = false; hasTextureSwizzle = false;
hasPixelBufferObject = false; hasPixelBufferObject = false;
hasSRGBFramebuffer = false;
#if defined(USE_GLES2) #if defined(USE_GLES2)
hasBGRA = false; hasBGRA = false;
@ -203,6 +204,12 @@ void CentralVideoSettings::init()
hasPixelBufferObject = true; hasPixelBufferObject = true;
Log::info("GLDriver", "ARB Pixel Buffer Object Present"); Log::info("GLDriver", "ARB Pixel Buffer Object Present");
} }
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB) &&
(hasGLExtension("GL_ARB_framebuffer_sRGB") || m_glsl == true))
{
hasSRGBFramebuffer = true;
Log::info("GLDriver", "ARB framebuffer sRGB Present");
}
// Only unset the high def textures if they are set as default. If the // Only unset the high def textures if they are set as default. If the
// user has enabled them (bit 1 set), then leave them enabled. // user has enabled them (bit 1 set), then leave them enabled.
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_HIGHDEFINITION_TEXTURES) && if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_HIGHDEFINITION_TEXTURES) &&
@ -231,7 +238,7 @@ void CentralVideoSettings::init()
} }
// Check if visual is sRGB-capable // Check if visual is sRGB-capable
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_CAPABLE) && if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKAROUND2) &&
m_glsl == true) m_glsl == true)
{ {
GLint param = GL_SRGB; GLint param = GL_SRGB;
@ -415,6 +422,11 @@ bool CentralVideoSettings::isEXTTextureFilterAnisotropicUsable() const
return hasTextureFilterAnisotropic; return hasTextureFilterAnisotropic;
} }
bool CentralVideoSettings::isARBSRGBFramebufferUsable() const
{
return hasSRGBFramebuffer;
}
#if defined(USE_GLES2) #if defined(USE_GLES2)
bool CentralVideoSettings::isEXTTextureFormatBGRA8888Usable() const bool CentralVideoSettings::isEXTTextureFormatBGRA8888Usable() const
{ {
@ -452,6 +464,11 @@ bool CentralVideoSettings::supportsAsyncInstanceUpload() const
return isARBBufferStorageUsable() && isARBImageLoadStoreUsable(); return isARBBufferStorageUsable() && isARBImageLoadStoreUsable();
} }
bool CentralVideoSettings::supportsTextureCompression() const
{
return isEXTTextureCompressionS3TCUsable() && isARBSRGBFramebufferUsable();
}
bool CentralVideoSettings::isShadowEnabled() const bool CentralVideoSettings::isShadowEnabled() const
{ {
return supportsShadows() && (UserConfigParams::m_shadows_resolution > 0); return supportsShadows() && (UserConfigParams::m_shadows_resolution > 0);
@ -464,7 +481,7 @@ bool CentralVideoSettings::isGlobalIlluminationEnabled() const
bool CentralVideoSettings::isTextureCompressionEnabled() const bool CentralVideoSettings::isTextureCompressionEnabled() const
{ {
return isEXTTextureCompressionS3TCUsable() && UserConfigParams::m_texture_compression; return supportsTextureCompression() && UserConfigParams::m_texture_compression;
} }
// See http://visual-computing.intel-research.net/art/publications/sdsm/ // See http://visual-computing.intel-research.net/art/publications/sdsm/

View File

@ -45,6 +45,7 @@ private:
bool hasTextureFilterAnisotropic; bool hasTextureFilterAnisotropic;
bool hasTextureSwizzle; bool hasTextureSwizzle;
bool hasPixelBufferObject; bool hasPixelBufferObject;
bool hasSRGBFramebuffer;
#if defined(USE_GLES2) #if defined(USE_GLES2)
bool hasBGRA; bool hasBGRA;
@ -88,6 +89,7 @@ public:
bool isEXTTextureFilterAnisotropicUsable() const; bool isEXTTextureFilterAnisotropicUsable() const;
bool isARBTextureSwizzleUsable() const; bool isARBTextureSwizzleUsable() const;
bool isARBPixelBufferObjectUsable() const; bool isARBPixelBufferObjectUsable() const;
bool isARBSRGBFramebufferUsable() const;
#if defined(USE_GLES2) #if defined(USE_GLES2)
bool isEXTTextureFormatBGRA8888Usable() const; bool isEXTTextureFormatBGRA8888Usable() const;
@ -103,6 +105,7 @@ public:
bool supportsAsyncInstanceUpload() const; bool supportsAsyncInstanceUpload() const;
bool supportsHardwareSkinning() const; bool supportsHardwareSkinning() const;
bool supportsThreadedTextureLoading() const; bool supportsThreadedTextureLoading() const;
bool supportsTextureCompression() const;
// "Macro" around feature support and user config // "Macro" around feature support and user config
bool isShadowEnabled() const; bool isShadowEnabled() const;

View File

@ -44,7 +44,7 @@ namespace GraphicsRestrictions
/** The list of names used in the XML file for the graphics /** The list of names used in the XML file for the graphics
* restriction types. They must be in the same order as the types. */ * restriction types. They must be in the same order as the types. */
std::array<std::string, 28> m_names_of_restrictions = { std::array<std::string, 29> m_names_of_restrictions = {
"UniformBufferObject", "UniformBufferObject",
"GeometryShader", "GeometryShader",
"DrawIndirect", "DrawIndirect",
@ -68,8 +68,9 @@ namespace GraphicsRestrictions
"DriverRecentEnough", "DriverRecentEnough",
"HighDefinitionTextures", "HighDefinitionTextures",
"AdvancedPipeline", "AdvancedPipeline",
"FramebufferSRGBWorking", "FramebufferSRGB",
"FramebufferSRGBCapable", "FramebufferSRGBWorkaround1",
"FramebufferSRGBWorkaround2",
"GI", "GI",
"ForceLegacyDevice", "ForceLegacyDevice",
"VertexIdWorking" "VertexIdWorking"

View File

@ -57,8 +57,9 @@ namespace GraphicsRestrictions
GR_DRIVER_RECENT_ENOUGH, GR_DRIVER_RECENT_ENOUGH,
GR_HIGHDEFINITION_TEXTURES, GR_HIGHDEFINITION_TEXTURES,
GR_ADVANCED_PIPELINE, GR_ADVANCED_PIPELINE,
GR_FRAMEBUFFER_SRGB_WORKING, GR_FRAMEBUFFER_SRGB,
GR_FRAMEBUFFER_SRGB_CAPABLE, GR_FRAMEBUFFER_SRGB_WORKAROUND1,
GR_FRAMEBUFFER_SRGB_WORKAROUND2,
GR_GI, GR_GI,
GR_FORCE_LEGACY_DEVICE, GR_FORCE_LEGACY_DEVICE,
GR_VERTEX_ID_WORKING, GR_VERTEX_ID_WORKING,

View File

@ -490,7 +490,8 @@ void IrrDriver::initDevice()
// Though we are able to force to use the proper format on mesa side by // Though we are able to force to use the proper format on mesa side by
// setting WithAlphaChannel parameter. // setting WithAlphaChannel parameter.
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
else if (CVS->needsSRGBCapableVisualWorkaround()) else if (CVS->isARBSRGBFramebufferUsable() &&
CVS->needsSRGBCapableVisualWorkaround())
{ {
Log::warn("irr_driver", "Created visual is not sRGB-capable. " Log::warn("irr_driver", "Created visual is not sRGB-capable. "
"Re-creating device to workaround the issue."); "Re-creating device to workaround the issue.");

View File

@ -1574,11 +1574,13 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
} }
// Workaround a bug with srgb fbo on sandy bridge windows // Workaround a bug with srgb fbo on sandy bridge windows
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKING)) if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKAROUND1) &&
CVS->isARBSRGBFramebufferUsable())
return in_fbo; return in_fbo;
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
glEnable(GL_FRAMEBUFFER_SRGB); if (CVS->isARBSRGBFramebufferUsable())
glEnable(GL_FRAMEBUFFER_SRGB);
#endif #endif
out_fbo = &rtts->getFBO(FBO_MLAA_COLORS); out_fbo = &rtts->getFBO(FBO_MLAA_COLORS);
out_fbo->bind(); out_fbo->bind();
@ -1596,7 +1598,8 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
PROFILER_POP_CPU_MARKER(); PROFILER_POP_CPU_MARKER();
} }
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
glDisable(GL_FRAMEBUFFER_SRGB); if (CVS->isARBSRGBFramebufferUsable())
glDisable(GL_FRAMEBUFFER_SRGB);
#endif #endif
return out_fbo; return out_fbo;

View File

@ -19,6 +19,7 @@
#include "graphics/render_target.hpp" #include "graphics/render_target.hpp"
#include "graphics/2dutils.hpp" #include "graphics/2dutils.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/glwrap.hpp" #include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/rtts.hpp" #include "graphics/rtts.hpp"
@ -148,14 +149,16 @@ void GL3RenderTarget::draw2DImage(const irr::core::rect<s32>& dest_rect,
irr::core::rect<s32> source_rect(0, 0, m_frame_buffer->getWidth(), irr::core::rect<s32> source_rect(0, 0, m_frame_buffer->getWidth(),
m_frame_buffer->getHeight()); m_frame_buffer->getHeight());
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
glEnable(GL_FRAMEBUFFER_SRGB); if (CVS->isARBSRGBFramebufferUsable())
glEnable(GL_FRAMEBUFFER_SRGB);
#endif #endif
draw2DImageFromRTT(m_frame_buffer->getRTT()[0], draw2DImageFromRTT(m_frame_buffer->getRTT()[0],
m_frame_buffer->getWidth(), m_frame_buffer->getHeight(), m_frame_buffer->getWidth(), m_frame_buffer->getHeight(),
dest_rect, source_rect, dest_rect, source_rect,
clip_rect, colors, use_alpha_channel_of_texture); clip_rect, colors, use_alpha_channel_of_texture);
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
glDisable(GL_FRAMEBUFFER_SRGB); if (CVS->isARBSRGBFramebufferUsable())
glDisable(GL_FRAMEBUFFER_SRGB);
#endif #endif
} // draw2DImage } // draw2DImage

View File

@ -101,10 +101,11 @@ RTT::RTT(size_t width, size_t height, float rtt_scale)
diffuse_specular_internal_format = GL_RGBA8; diffuse_specular_internal_format = GL_RGBA8;
type = GL_UNSIGNED_BYTE; type = GL_UNSIGNED_BYTE;
} }
srgb_internal_format = GL_RGBA8;
#endif #endif
if (!CVS->isARBSRGBFramebufferUsable())
srgb_internal_format = GL_RGBA8;
RenderTargetTextures[RTT_TMP1] = generateRTT(res, rgba_internal_format, rgba_format, type); RenderTargetTextures[RTT_TMP1] = generateRTT(res, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_TMP2] = generateRTT(res, rgba_internal_format, rgba_format, type); RenderTargetTextures[RTT_TMP2] = generateRTT(res, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_TMP3] = generateRTT(res, rgba_internal_format, rgba_format, type); RenderTargetTextures[RTT_TMP3] = generateRTT(res, rgba_internal_format, rgba_format, type);

View File

@ -305,7 +305,8 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
{ {
// We need a cleared depth buffer for some effect (eg particles depth blending) // We need a cleared depth buffer for some effect (eg particles depth blending)
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKING)) if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKAROUND1) &&
CVS->isARBSRGBFramebufferUsable())
glDisable(GL_FRAMEBUFFER_SRGB); glDisable(GL_FRAMEBUFFER_SRGB);
#endif #endif
m_rtts->getFBO(FBO_NORMAL_AND_DEPTHS).bind(); m_rtts->getFBO(FBO_NORMAL_AND_DEPTHS).bind();
@ -318,7 +319,8 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
vp.LowerRightCorner.Y - vp.UpperLeftCorner.Y); vp.LowerRightCorner.Y - vp.UpperLeftCorner.Y);
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKING)) if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKAROUND1) &&
CVS->isARBSRGBFramebufferUsable())
glEnable(GL_FRAMEBUFFER_SRGB); glEnable(GL_FRAMEBUFFER_SRGB);
#endif #endif
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
@ -495,7 +497,8 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
if (!CVS->isDefferedEnabled() && !forceRTT) if (!CVS->isDefferedEnabled() && !forceRTT)
{ {
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
glDisable(GL_FRAMEBUFFER_SRGB); if (CVS->isARBSRGBFramebufferUsable())
glDisable(GL_FRAMEBUFFER_SRGB);
#endif #endif
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
@ -603,13 +606,15 @@ void ShaderBasedRenderer::renderPostProcessing(Camera * const camera)
else else
{ {
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
glEnable(GL_FRAMEBUFFER_SRGB); if (CVS->isARBSRGBFramebufferUsable())
glEnable(GL_FRAMEBUFFER_SRGB);
#endif #endif
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
camera->activate(); camera->activate();
m_post_processing->renderPassThrough(fbo->getRTT()[0], viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y); m_post_processing->renderPassThrough(fbo->getRTT()[0], viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
glDisable(GL_FRAMEBUFFER_SRGB); if (CVS->isARBSRGBFramebufferUsable())
glDisable(GL_FRAMEBUFFER_SRGB);
#endif #endif
} }
} //renderPostProcessing } //renderPostProcessing
@ -811,7 +816,7 @@ void ShaderBasedRenderer::render(float dt)
irr_driver->getSceneManager()->setActiveCamera(camnode); irr_driver->getSceneManager()->setActiveCamera(camnode);
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
if (!CVS->isDefferedEnabled()) if (!CVS->isDefferedEnabled() && CVS->isARBSRGBFramebufferUsable())
glEnable(GL_FRAMEBUFFER_SRGB); glEnable(GL_FRAMEBUFFER_SRGB);
#endif #endif
@ -961,7 +966,7 @@ void ShaderBasedRenderer::preloadShaderFiles()
sfm->addShaderFile("screenquad.vert", GL_VERTEX_SHADER); sfm->addShaderFile("screenquad.vert", GL_VERTEX_SHADER);
sfm->addShaderFile("tonemap.frag", GL_FRAGMENT_SHADER); sfm->addShaderFile("tonemap.frag", GL_FRAGMENT_SHADER);
if (!GraphicsRestrictions::isDisabled if (!GraphicsRestrictions::isDisabled
(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKING)) (GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKAROUND1))
sfm->addShaderFile("passthrough.frag", GL_FRAGMENT_SHADER); sfm->addShaderFile("passthrough.frag", GL_FRAGMENT_SHADER);
sfm->addShaderFile("billboard.vert", GL_VERTEX_SHADER); sfm->addShaderFile("billboard.vert", GL_VERTEX_SHADER);

View File

@ -168,6 +168,8 @@ GLuint ShaderFilesManager::loadShader(const std::string &file, unsigned type)
code << "#define Needs_Vertex_Id_Workaround\n"; code << "#define Needs_Vertex_Id_Workaround\n";
if (CVS->isDefferedEnabled()) if (CVS->isDefferedEnabled())
code << "#define Advanced_Lighting_Enabled\n"; code << "#define Advanced_Lighting_Enabled\n";
if (CVS->isARBSRGBFramebufferUsable())
code << "#define sRGB_Framebuffer_Usable\n";
#if !defined(USE_GLES2) #if !defined(USE_GLES2)
// shader compilation fails with some drivers if there is no precision // shader compilation fails with some drivers if there is no precision

View File

@ -178,14 +178,17 @@ void Skybox::generateCubeMapFromTextures()
} }
glBindTexture(GL_TEXTURE_CUBE_MAP, m_cube_map); glBindTexture(GL_TEXTURE_CUBE_MAP, m_cube_map);
#if !defined(USE_GLES2)
GLint internal_format = CVS->isTextureCompressionEnabled() ? bool needs_srgb_format = CVS->isARBSRGBFramebufferUsable() ||
GL_COMPRESSED_SRGB_ALPHA : GL_SRGB_ALPHA; CVS->isDefferedEnabled();
GLint format = GL_BGRA;
#else
GLint internal_format = CVS->isDefferedEnabled() ? GL_SRGB8_ALPHA8
: GL_RGBA8;
GLint format = GL_RGBA; GLint format = GL_RGBA;
GLint internal_format = needs_srgb_format ? GL_SRGB8_ALPHA8 : GL_RGBA8;
#if !defined(USE_GLES2)
if (CVS->isTextureCompressionEnabled())
internal_format = needs_srgb_format ? GL_COMPRESSED_SRGB_ALPHA
: GL_COMPRESSED_RGBA;
format = GL_BGRA;
#endif #endif
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,

View File

@ -50,12 +50,14 @@ STKTexture::STKTexture(const std::string& path, TexConfig* tc, bool no_upload)
m_material = material_manager->getMaterialFor(this); m_material = material_manager->getMaterialFor(this);
} }
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
if (m_tex_config && !CVS->isGLSL()) if (m_tex_config)
m_tex_config->m_srgb = false; {
#ifdef USE_GLES2 if ((!CVS->isARBSRGBFramebufferUsable() && !CVS->isDefferedEnabled()) ||
if (m_tex_config && !CVS->isDefferedEnabled()) !CVS->isGLSL())
m_tex_config->m_srgb = false; {
#endif m_tex_config->m_srgb = false;
}
}
if (!CVS->isARBTextureSwizzleUsable()) if (!CVS->isARBTextureSwizzleUsable())
m_single_channel = false; m_single_channel = false;
#endif #endif
@ -332,10 +334,12 @@ void STKTexture::formatConversion(uint8_t* data, unsigned int* format,
if (alpha > 0.0f) if (alpha > 0.0f)
{ {
alpha /= 255.0f; alpha /= 255.0f;
#if defined(USE_GLES2)
if (CVS->isDefferedEnabled()) if (CVS->isARBSRGBFramebufferUsable() ||
#endif CVS->isDefferedEnabled())
{
alpha = pow(alpha, 1.0f / 2.2f); alpha = pow(alpha, 1.0f / 2.2f);
}
} }
data[i * 4] = (uint8_t)(data[i * 4] * alpha); data[i * 4] = (uint8_t)(data[i * 4] * alpha);
data[i * 4 + 1] = (uint8_t)(data[i * 4 + 1] * alpha); data[i * 4 + 1] = (uint8_t)(data[i * 4 + 1] * alpha);