From 0538106d52b5169ff4a8eec90ae3c3bf468d6d28 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 10 May 2022 13:54:03 +0200 Subject: [PATCH] glgsg: Fix half float color buffers with GLES 3 / WebGL 2 Part of fix for #1296 --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index ea573a13e0..983e7cef23 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -857,6 +857,26 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, gl_format = GL_DEPTH_COMPONENT16; } break; +#ifndef OPENGLES_1 + case RTP_aux_hrgba_0: + case RTP_aux_hrgba_1: + case RTP_aux_hrgba_2: + case RTP_aux_hrgba_3: + case RTP_aux_float_0: + case RTP_aux_float_1: + case RTP_aux_float_2: + case RTP_aux_float_3: + if (glgsg->has_extension("GL_EXT_color_buffer_float")) { + if (slot >= RTP_aux_float_0 && slot <= RTP_aux_float_3) { + gl_format = GL_RGBA32F; + } else { + gl_format = GL_RGBA16F; + } + } + else if (glgsg->has_extension("GL_EXT_color_buffer_half_float")) { + gl_format = GL_RGBA16F_EXT; + } +#endif // NB: we currently use RTP_stencil to store the right eye for stereo. // case RTP_stencil: gl_format = GL_STENCIL_INDEX8; break default: @@ -914,9 +934,12 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, } #ifndef OPENGLES_1 } else if (_fb_properties.get_float_color() && - _fb_properties.get_color_bits() > 16 * 3 && glgsg->has_extension("GL_EXT_color_buffer_float")) { - gl_format = GL_RGBA32F_EXT; + if (_fb_properties.get_color_bits() > 16 * 3) { + gl_format = GL_RGBA32F; + } else { + gl_format = GL_RGBA16F; + } } else if (_fb_properties.get_float_color() && glgsg->has_extension("GL_EXT_color_buffer_half_float")) { gl_format = GL_RGBA16F_EXT;