]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Use the invariant keyword on gl_Position on GLSL 1.20 or higher and GLSL ES
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 6 Aug 2017 15:33:55 +0000 (15:33 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 6 Aug 2017 15:33:55 +0000 (15:33 +0000)
1.00 or higher, this should resolve zfighting between light polygons and
base surfaces.

A long long time ago this was using ftransform() which ensured invariance but use of the invariant keyword was not added when we switched away from that.

Thanks for the bug report:
https://www.reddit.com/r/quake/comments/6rwwm5/need_some_help_getting_quake_running_with/

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12336 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
shader_glsl.h

index 92e0d76c4e8fab5350a0d5eb77815dac2ad8f003..6a316432495af90663d7c35e9fc3795caa040d0a 100644 (file)
@@ -1115,6 +1115,27 @@ static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode
                geomstrings_list[geomstrings_count++] = "#define GLSL130\n";
                fragstrings_list[fragstrings_count++] = "#define GLSL130\n";
        }
                geomstrings_list[geomstrings_count++] = "#define GLSL130\n";
                fragstrings_list[fragstrings_count++] = "#define GLSL130\n";
        }
+       // if we can do #version 120, we should (this adds the invariant keyword)
+       else if(vid.support.glshaderversion >= 120)
+       {
+               vertstrings_list[vertstrings_count++] = "#version 120\n";
+               geomstrings_list[geomstrings_count++] = "#version 120\n";
+               fragstrings_list[fragstrings_count++] = "#version 120\n";
+               vertstrings_list[vertstrings_count++] = "#define GLSL120\n";
+               geomstrings_list[geomstrings_count++] = "#define GLSL120\n";
+               fragstrings_list[fragstrings_count++] = "#define GLSL120\n";
+       }
+       // GLES also adds several things from GLSL120
+       switch(vid.renderpath)
+       {
+       case RENDERPATH_GLES2:
+               vertstrings_list[vertstrings_count++] = "#define GLES\n";
+               geomstrings_list[geomstrings_count++] = "#define GLES\n";
+               fragstrings_list[fragstrings_count++] = "#define GLES\n";
+               break;
+       default:
+               break;
+       }
 
        // the first pretext is which type of shader to compile as
        // (later these will all be bound together as a program object)
 
        // the first pretext is which type of shader to compile as
        // (later these will all be bound together as a program object)
index 90d5d770db2fe73fc52326f6e4dcb1479dc51a28..f9be074eff2c1031bcaa8483187d5b58171c45cf 100644 (file)
@@ -37,6 +37,9 @@
 "# endif\n",
 "#endif\n",
 "\n",
 "# endif\n",
 "#endif\n",
 "\n",
+"#if defined(GLSL120) || defined(GLSL130) || defined(GLSL140) || defined(GLES)\n"
+"invariant gl_Position; // fix for lighting polygons not matching base surface\n",
+"# endif\n",
 "#if defined(GLSL130) || defined(GLSL140)\n",
 "precision highp float;\n",
 "# ifdef VERTEX_SHADER\n",
 "#if defined(GLSL130) || defined(GLSL140)\n",
 "precision highp float;\n",
 "# ifdef VERTEX_SHADER\n",