Procházet zdrojové kódy

glgsg: Fix half float color buffers with GLES 3 / WebGL 2

Part of fix for #1296
rdb před 3 roky
rodič
revize
0538106d52
1 změnil soubory, kde provedl 25 přidání a 2 odebrání
  1. 25 2
      panda/src/glstuff/glGraphicsBuffer_src.cxx

+ 25 - 2
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;
         gl_format = GL_DEPTH_COMPONENT16;
       }
       }
       break;
       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.
     // NB: we currently use RTP_stencil to store the right eye for stereo.
     // case RTP_stencil: gl_format = GL_STENCIL_INDEX8; break
     // case RTP_stencil: gl_format = GL_STENCIL_INDEX8; break
     default:
     default:
@@ -914,9 +934,12 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
         }
         }
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
       } else if (_fb_properties.get_float_color() &&
       } else if (_fb_properties.get_float_color() &&
-                 _fb_properties.get_color_bits() > 16 * 3 &&
                  glgsg->has_extension("GL_EXT_color_buffer_float")) {
                  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() &&
       } else if (_fb_properties.get_float_color() &&
                  glgsg->has_extension("GL_EXT_color_buffer_half_float")) {
                  glgsg->has_extension("GL_EXT_color_buffer_half_float")) {
         gl_format = GL_RGBA16F_EXT;
         gl_format = GL_RGBA16F_EXT;