Browse Source

webgl: Fix precision issues with default shaders

rdb 1 year ago
parent
commit
8ff71aeb15
1 changed files with 13 additions and 3 deletions
  1. 13 3
      panda/src/glstuff/glGraphicsStateGuardian_src.cxx

+ 13 - 3
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -189,16 +189,22 @@ static const string default_vshader =
   "in vec4 p3d_MultiTexCoord0;\n"
   "out vec3 texcoord;\n"
   "out vec4 color;\n"
+  "uniform mat4 p3d_ModelViewProjectionMatrix;\n"
 #else
   "#version 100\n"
   "precision mediump float;\n"
   "attribute vec4 p3d_Vertex;\n"
   "attribute vec4 p3d_Color;\n"
   "attribute vec4 p3d_MultiTexCoord0;\n"
-  "varying vec3 texcoord;\n"
   "varying lowp vec4 color;\n"
-#endif
+  "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
+  "varying highp vec3 texcoord;\n"
+  "uniform highp mat4 p3d_ModelViewProjectionMatrix;\n"
+  "#else\n"
+  "varying mediump vec3 texcoord;\n"
   "uniform mat4 p3d_ModelViewProjectionMatrix;\n"
+  "#endif\n"
+#endif
   "uniform mat4 p3d_TextureMatrix;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "void main(void) {\n"
@@ -266,7 +272,11 @@ static const string default_fshader =
 #else
   "#version 100\n"
   "precision mediump float;\n"
-  "varying vec3 texcoord;\n"
+  "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
+  "varying highp vec3 texcoord;\n"
+  "#else\n"
+  "varying mediump vec3 texcoord;\n"
+  "#endif\n"
   "varying lowp vec4 color;\n"
   "uniform lowp sampler2D p3d_Texture0;\n"
   "uniform lowp vec4 p3d_TexAlphaOnly;\n"