diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-28 09:06:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-28 09:06:38 +0100 |
commit | da880520caf978b568b4db1585d7a03df5e2a569 (patch) | |
tree | 658f935fbe677c6f205891027a617255daafa042 | |
parent | a87a871250cb7369b701bab5daf11999bdb20b70 (diff) | |
parent | 192aacd5d742e514523f9764e2b973372fe177f0 (diff) |
Merge pull request #33963 from clayjohn/GLES3-sky-mipmaps-on-mobile
Fix radiance map generation on mobile
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 4509c9d17e..07d7416905 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1794,13 +1794,21 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra glActiveTexture(GL_TEXTURE0); glBindTexture(texture->target, texture->tex_id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 10); - // Need Mipmaps regardless of whether they are set in import by user + glTexParameteri(texture->target, GL_TEXTURE_BASE_LEVEL, 0); +#ifdef GLES_OVER_GL + glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, int(Math::floor(Math::log(float(texture->width)) / Math::log(2.0f)))); 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_T, GL_REPEAT); +#ifdef GLES_OVER_GL 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); 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); +#ifdef GLES_OVER_GL 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_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); glBindFramebuffer(GL_FRAMEBUFFER, tmp_fb2); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_tex, 0); +#ifdef GLES_OVER_GL 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_SOURCE_PANORAMA, true); |