Some fixes for GLES renderer.
- Don't use BGRA format at all. It doesn't work with non-typical cases (i.e. with srgb or compressed textures) and also casues artifacts on some android devices. I kept the extension in central settings, but it probably won't be used. - Use sRGB texture format when advanced lighting is enabled. This makes it closer to the original OpenGL renderer and also avoids to have even more #ifdef's for sRGB conversions. - Keep RGBA textures for non-advanced lighting to make it simpler. Now advanced lighting in GLES looks almost the same as in OpenGL 3.x (without shadows/GI)
This commit is contained in:
parent
5931e20f8b
commit
a7f0d3762c
@ -40,7 +40,7 @@ void main(void)
|
||||
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
|
||||
}
|
||||
|
||||
#ifdef GL_ES
|
||||
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= color.xyz;
|
||||
#else
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
|
@ -16,7 +16,13 @@ void main(void)
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
if (col.a < 0.5) discard;
|
||||
|
||||
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= color.xyz;
|
||||
#else
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#endif
|
||||
|
||||
FragColor = vec4(col.xyz, 1.);
|
||||
}
|
||||
|
@ -25,9 +25,14 @@ void main(void)
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
if (col.a * color.a < 0.5) discard;
|
||||
|
||||
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= color.xyz;
|
||||
#else
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#endif
|
||||
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
if (color_change.x > 0.0)
|
||||
{
|
||||
|
@ -13,7 +13,9 @@ void main()
|
||||
|
||||
// Uncharted2 tonemap with Auria's custom coefficients
|
||||
vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06);
|
||||
#if !(defined(GL_ES) && defined(Advanced_Lighting_Enabled))
|
||||
perChannel = pow(perChannel, vec4(2.2));
|
||||
#endif
|
||||
|
||||
vec2 inside = uv - 0.5;
|
||||
float vignette = 1. - dot(inside, inside) * vignette_weight;
|
||||
|
@ -14,7 +14,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
#ifdef GL_ES
|
||||
#if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
|
||||
DiffuseComponent = pow(DiffuseComponent, vec3(1. / 2.2));
|
||||
SpecularComponent = pow(SpecularComponent, vec3(1. / 2.2));
|
||||
#endif
|
||||
|
@ -164,6 +164,8 @@ GLuint ShaderFilesManager::loadShader(const std::string &file, unsigned type)
|
||||
code << "#define VSLayer\n";
|
||||
if (CVS->needsRGBBindlessWorkaround())
|
||||
code << "#define SRGBBindlessFix\n";
|
||||
if (CVS->isDefferedEnabled())
|
||||
code << "#define Advanced_Lighting_Enabled\n";
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
// shader compilation fails with some drivers if there is no precision
|
||||
|
@ -163,19 +163,6 @@ void Skybox::generateCubeMapFromTextures()
|
||||
assert(img != NULL);
|
||||
img->copyToScaling(rgba[i], size, size);
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
if (CVS->isEXTTextureFormatBGRA8888Usable())
|
||||
{
|
||||
// BGRA image returned by getTextureImage causes black sky in gles
|
||||
for (unsigned int j = 0; j < size * size; j++)
|
||||
{
|
||||
char tmp_val = rgba[i][j * 4];
|
||||
rgba[i][j * 4] = rgba[i][j * 4 + 2];
|
||||
rgba[i][j * 4 + 2] = tmp_val;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (i == 2 || i == 3)
|
||||
{
|
||||
char *tmp = new char[size * size * 4];
|
||||
@ -196,7 +183,8 @@ void Skybox::generateCubeMapFromTextures()
|
||||
GL_COMPRESSED_SRGB_ALPHA : GL_SRGB_ALPHA;
|
||||
GLint format = GL_BGRA;
|
||||
#else
|
||||
GLint internal_format = GL_RGBA8;
|
||||
GLint internal_format = CVS->isDefferedEnabled() ? GL_SRGB8_ALPHA8
|
||||
: GL_RGBA8;
|
||||
GLint format = GL_RGBA;
|
||||
#endif
|
||||
|
||||
|
@ -565,8 +565,6 @@ void SphericalHarmonics::setTextures(const std::vector<video::ITexture *> &spher
|
||||
assert(img != NULL);
|
||||
img->copyToScaling(sh_rgba[i], sh_w, sh_h);
|
||||
#if defined(USE_GLES2)
|
||||
if (!CVS->isEXTTextureFormatBGRA8888Usable())
|
||||
{
|
||||
// Code here assume color format is BGRA
|
||||
for (unsigned int j = 0; j < sh_w * sh_h; j++)
|
||||
{
|
||||
@ -574,7 +572,6 @@ void SphericalHarmonics::setTextures(const std::vector<video::ITexture *> &spher
|
||||
sh_rgba[i][j * 4] = sh_rgba[i][j * 4 + 2];
|
||||
sh_rgba[i][j * 4 + 2] = tmp_val;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} //for (unsigned i = 0; i < 6; i++)
|
||||
|
||||
|
@ -52,6 +52,10 @@ STKTexture::STKTexture(const std::string& path, TexConfig* tc, bool no_upload)
|
||||
#ifndef SERVER_ONLY
|
||||
if (m_tex_config && !CVS->isGLSL())
|
||||
m_tex_config->m_srgb = false;
|
||||
#ifdef USE_GLES2
|
||||
if (m_tex_config && !CVS->isDefferedEnabled())
|
||||
m_tex_config->m_srgb = false;
|
||||
#endif
|
||||
if (!CVS->isARBTextureSwizzleUsable())
|
||||
m_single_channel = false;
|
||||
#endif
|
||||
@ -215,7 +219,8 @@ void STKTexture::reload(bool no_upload, uint8_t* preload_data,
|
||||
const unsigned int w = m_size.Width;
|
||||
const unsigned int h = m_size.Height;
|
||||
unsigned int format = m_single_channel ? GL_RED : GL_BGRA;
|
||||
unsigned int internal_format = m_single_channel ? GL_R8 : GL_RGBA;
|
||||
unsigned int internal_format = m_single_channel ? GL_R8 : isSrgb() ?
|
||||
GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
if (isMeshTexture() && CVS->isTextureCompressionEnabled())
|
||||
@ -224,12 +229,8 @@ void STKTexture::reload(bool no_upload, uint8_t* preload_data,
|
||||
isSrgb() ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT :
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
}
|
||||
else
|
||||
{
|
||||
internal_format =
|
||||
m_single_channel ? GL_R8 : isSrgb() ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!useThreadedLoading())
|
||||
formatConversion(data, &format, w, h);
|
||||
|
||||
@ -303,7 +304,7 @@ void STKTexture::formatConversion(uint8_t* data, unsigned int* format,
|
||||
unsigned int w, unsigned int h) const
|
||||
{
|
||||
#if defined(USE_GLES2)
|
||||
if (!CVS->isEXTTextureFormatBGRA8888Usable() && !m_single_channel)
|
||||
if (!m_single_channel)
|
||||
{
|
||||
if (format)
|
||||
*format = GL_RGBA;
|
||||
|
Loading…
Reference in New Issue
Block a user