Merge pull request #33963 from clayjohn/GLES3-sky-mipmaps-on-mobile

Fix radiance map generation on mobile
This commit is contained in:
Rémi Verschelde 2019-11-28 09:06:38 +01:00 committed by GitHub
commit da880520ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1794,13 +1794,21 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(texture->target, texture->tex_id); glBindTexture(texture->target, texture->tex_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(texture->target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 10); #ifdef GLES_OVER_GL
// Need Mipmaps regardless of whether they are set in import by user glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, int(Math::floor(Math::log(float(texture->width)) / Math::log(2.0f))));
glGenerateMipmap(texture->target); glGenerateMipmap(texture->target);
#else
glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, 0);
#endif
// Need Mipmaps regardless of whether they are set in import by user
glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_REPEAT);
#ifdef GLES_OVER_GL
glTexParameterf(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
#else
glTexParameterf(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
#endif
glTexParameterf(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (config.srgb_decode_supported && texture->srgb && !texture->using_srgb) { if (config.srgb_decode_supported && texture->srgb && !texture->using_srgb) {
@ -1925,7 +1933,11 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2); glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2);
#ifdef GLES_OVER_GL
if (j < 3) { if (j < 3) {
#else
if (j == 0) {
#endif
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true); shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true); shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true);
@ -2051,7 +2063,11 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size, size * 2, 0, format, type, NULL); glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size, size * 2, 0, format, type, NULL);
glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2); glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_tex, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_tex, 0);
#ifdef GLES_OVER_GL
if (lod < 3) { if (lod < 3) {
#else
if (lod == 0) {
#endif
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true); shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DUAL_PARABOLOID, true);
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true); shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true);