Merge remote-tracking branch 'origin/master' into advanced_recording

This commit is contained in:
Benau 2017-03-31 11:50:24 +08:00
commit 21ff135b04
12 changed files with 56 additions and 44 deletions

View File

@ -40,7 +40,7 @@ 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);
} }
#ifdef GL_ES #if defined(GL_ES) && !defined(Advanced_Lighting_Enabled)
col.xyz *= color.xyz; col.xyz *= color.xyz;
#else #else
col.xyz *= pow(color.xyz, vec3(2.2)); col.xyz *= pow(color.xyz, vec3(2.2));

View File

@ -16,7 +16,13 @@ void main(void)
col.xyz = pow(col.xyz, vec3(2.2)); col.xyz = pow(col.xyz, vec3(2.2));
#endif #endif
#endif #endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a < 0.5) discard; 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.); FragColor = vec4(col.xyz, 1.);
} }

View File

@ -25,8 +25,13 @@ void main(void)
col.xyz = pow(col.xyz, vec3(2.2)); col.xyz = pow(col.xyz, vec3(2.2));
#endif #endif
#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(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; float mask = texture(colorization_mask, uv).a;
if (color_change.x > 0.0) if (color_change.x > 0.0)

View File

@ -13,7 +13,9 @@ 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))
perChannel = pow(perChannel, vec4(2.2)); perChannel = pow(perChannel, vec4(2.2));
#endif
vec2 inside = uv - 0.5; vec2 inside = uv - 0.5;
float vignette = 1. - dot(inside, inside) * vignette_weight; float vignette = 1. - dot(inside, inside) * vignette_weight;

View File

@ -14,10 +14,6 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz; vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz; vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
float ao = texture(SSAO, tc).x; float ao = texture(SSAO, tc).x;
#ifdef GL_ES
DiffuseComponent = pow(DiffuseComponent, vec3(1. / 2.2));
SpecularComponent = pow(SpecularComponent, vec3(1. / 2.2));
#endif
vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue; vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue;
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);

View File

@ -557,24 +557,28 @@ namespace UserConfigParams
PARAM_DEFAULT(BoolUserConfigParam(false, "hq_mipmap", PARAM_DEFAULT(BoolUserConfigParam(false, "hq_mipmap",
&m_video_group, "Generate mipmap for textures using " &m_video_group, "Generate mipmap for textures using "
"high quality method with SSE")); "high quality method with SSE"));
// ---- Recording
PARAM_PREFIX GroupUserConfigParam m_recording_group
PARAM_DEFAULT( GroupUserConfigParam("Recording", "Recording Settings") );
PARAM_PREFIX BoolUserConfigParam m_record_bmp PARAM_PREFIX BoolUserConfigParam m_record_bmp
PARAM_DEFAULT(BoolUserConfigParam(false, "record_bmp", PARAM_DEFAULT(BoolUserConfigParam(false, "record_bmp",
&m_video_group, "Record video using uncompressed bitmap, notice: this " &m_recording_group, "Record video using uncompressed bitmap, notice: this "
"will require a lot of space and fast disk access.")); "will require a lot of space and fast disk access."));
PARAM_PREFIX BoolUserConfigParam m_limit_game_fps PARAM_PREFIX BoolUserConfigParam m_limit_game_fps
PARAM_DEFAULT(BoolUserConfigParam(true, "limit_game_fps", PARAM_DEFAULT(BoolUserConfigParam(true, "limit_game_fps",
&m_video_group, "Limit game framerate not beyond the fps of recording " &m_recording_group, "Limit game framerate not beyond the fps of recording "
"video.")); "video."));
PARAM_PREFIX IntUserConfigParam m_record_compression PARAM_PREFIX IntUserConfigParam m_record_compression
PARAM_DEFAULT(IntUserConfigParam(90, "record_compression", PARAM_DEFAULT(IntUserConfigParam(90, "record_compression",
&m_video_group, "Specify the compression level of recording video")); &m_recording_group, "Specify the compression level of recording video"));
PARAM_PREFIX IntUserConfigParam m_record_fps PARAM_PREFIX IntUserConfigParam m_record_fps
PARAM_DEFAULT(IntUserConfigParam(30, "record_fps", PARAM_DEFAULT(IntUserConfigParam(30, "record_fps",
&m_video_group, "Specify the fps of recording video")); &m_recording_group, "Specify the fps of recording video"));
// ---- Debug - not saved to config file // ---- Debug - not saved to config file
/** If gamepad debugging is enabled. */ /** If gamepad debugging is enabled. */

View File

@ -293,7 +293,12 @@ RTT::RTT(size_t width, size_t height, float rtt_scale)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).bind(); getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).bind();
glClearColor(.5, .5, .5, .5); float color = 0.5;
#if defined(USE_GLES2)
if (!CVS->isDefferedEnabled())
color = pow(color, 1. / 2.2);
#endif
glClearColor(color, color, color, color);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
#if !defined(USE_GLES2) #if !defined(USE_GLES2)

View File

@ -164,12 +164,14 @@ GLuint ShaderFilesManager::loadShader(const std::string &file, unsigned type)
code << "#define VSLayer\n"; code << "#define VSLayer\n";
if (CVS->needsRGBBindlessWorkaround()) if (CVS->needsRGBBindlessWorkaround())
code << "#define SRGBBindlessFix\n"; code << "#define SRGBBindlessFix\n";
if (CVS->isDefferedEnabled())
code << "#define Advanced_Lighting_Enabled\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
// qualifier // qualifier
if (type == GL_FRAGMENT_SHADER) if (type == GL_FRAGMENT_SHADER)
code << "precision mediump float;\n"; code << "precision highp float;\n";
#else #else
int range[2], precision; int range[2], precision;
glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, range, glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, range,

View File

@ -163,19 +163,6 @@ void Skybox::generateCubeMapFromTextures()
assert(img != NULL); assert(img != NULL);
img->copyToScaling(rgba[i], size, size); 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) if (i == 2 || i == 3)
{ {
char *tmp = new char[size * size * 4]; char *tmp = new char[size * size * 4];
@ -196,7 +183,8 @@ void Skybox::generateCubeMapFromTextures()
GL_COMPRESSED_SRGB_ALPHA : GL_SRGB_ALPHA; GL_COMPRESSED_SRGB_ALPHA : GL_SRGB_ALPHA;
GLint format = GL_BGRA; GLint format = GL_BGRA;
#else #else
GLint internal_format = GL_RGBA8; GLint internal_format = CVS->isDefferedEnabled() ? GL_SRGB8_ALPHA8
: GL_RGBA8;
GLint format = GL_RGBA; GLint format = GL_RGBA;
#endif #endif

View File

@ -565,15 +565,12 @@ void SphericalHarmonics::setTextures(const std::vector<video::ITexture *> &spher
assert(img != NULL); assert(img != NULL);
img->copyToScaling(sh_rgba[i], sh_w, sh_h); img->copyToScaling(sh_rgba[i], sh_w, sh_h);
#if defined(USE_GLES2) #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++)
{ {
// Code here assume color format is BGRA char tmp_val = sh_rgba[i][j * 4];
for (unsigned int j = 0; j < sh_w * sh_h; j++) sh_rgba[i][j * 4] = sh_rgba[i][j * 4 + 2];
{ sh_rgba[i][j * 4 + 2] = tmp_val;
char tmp_val = sh_rgba[i][j * 4];
sh_rgba[i][j * 4] = sh_rgba[i][j * 4 + 2];
sh_rgba[i][j * 4 + 2] = tmp_val;
}
} }
#endif #endif
} //for (unsigned i = 0; i < 6; i++) } //for (unsigned i = 0; i < 6; i++)

View File

@ -52,6 +52,10 @@ STKTexture::STKTexture(const std::string& path, TexConfig* tc, bool no_upload)
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
if (m_tex_config && !CVS->isGLSL()) if (m_tex_config && !CVS->isGLSL())
m_tex_config->m_srgb = false; 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()) if (!CVS->isARBTextureSwizzleUsable())
m_single_channel = false; m_single_channel = false;
#endif #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 w = m_size.Width;
const unsigned int h = m_size.Height; const unsigned int h = m_size.Height;
unsigned int format = m_single_channel ? GL_RED : GL_BGRA; 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 !defined(USE_GLES2)
if (isMeshTexture() && CVS->isTextureCompressionEnabled()) 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 : isSrgb() ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT :
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
} }
else
{
internal_format =
m_single_channel ? GL_R8 : isSrgb() ? GL_SRGB8_ALPHA8 : GL_RGBA8;
}
#endif #endif
if (!useThreadedLoading()) if (!useThreadedLoading())
formatConversion(data, &format, w, h); 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 unsigned int w, unsigned int h) const
{ {
#if defined(USE_GLES2) #if defined(USE_GLES2)
if (!CVS->isEXTTextureFormatBGRA8888Usable() && !m_single_channel) if (!m_single_channel)
{ {
if (format) if (format)
*format = GL_RGBA; *format = GL_RGBA;
@ -321,7 +322,13 @@ void STKTexture::formatConversion(uint8_t* data, unsigned int* format,
{ {
float alpha = data[4 * i + 3]; float alpha = data[4 * i + 3];
if (alpha > 0.0f) if (alpha > 0.0f)
alpha = pow(alpha / 255.f, 1.f / 2.2f); {
alpha /= 255.0f;
#if defined(USE_GLES2)
if (CVS->isDefferedEnabled())
#endif
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);
data[i * 4 + 2] = (uint8_t)(data[i * 4 + 2] * alpha); data[i * 4 + 2] = (uint8_t)(data[i * 4 + 2] * alpha);

View File

@ -119,7 +119,7 @@ float MainLoop::getLimitedDt()
// When in menus, reduce FPS much, it's not necessary to push to the maximum for plain menus // When in menus, reduce FPS much, it's not necessary to push to the maximum for plain menus
const int max_fps = (irr_driver->isRecording() && const int max_fps = (irr_driver->isRecording() &&
UserConfigParams::m_limit_game_fps ? UserConfigParams::m_record_fps : UserConfigParams::m_limit_game_fps ? UserConfigParams::m_record_fps :
StateManager::get()->throttleFPS() ? 30 : UserConfigParams::m_max_fps); StateManager::get()->throttleFPS() ? 60 : UserConfigParams::m_max_fps);
if (dt > 0) if (dt > 0)
{ {
const int current_fps = (int)(1000.0f / dt); const int current_fps = (int)(1000.0f / dt);