mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-02-22 11:52:06 +00:00
fixed GL2 portal clip plane not being used
This commit is contained in:
parent
815b8d0c02
commit
5b591f270d
2 changed files with 78 additions and 4 deletions
|
@ -100,6 +100,9 @@ chg: with r_backend GL3, depth fade with MSAA now requires GLSL 4.00 at a minimu
|
||||||
|
|
||||||
chg: with r_backend GL3, alpha to coverage now requires GLSL 4.00 at a minimum
|
chg: with r_backend GL3, alpha to coverage now requires GLSL 4.00 at a minimum
|
||||||
|
|
||||||
|
fix: with r_backend GL2, the extra clip plane for mirror/portal surfaces was not being used
|
||||||
|
this quick fix is likely to fail for some drivers and vendors due to its use of deprecated features
|
||||||
|
|
||||||
fix: long demo file names would cause video recording to output files with no extension or outright fail
|
fix: long demo file names would cause video recording to output files with no extension or outright fail
|
||||||
|
|
||||||
fix: invalid skybox texture mip-mapping and filtering settings (e.g. cpm25 skybox seams)
|
fix: invalid skybox texture mip-mapping and filtering settings (e.g. cpm25 skybox seams)
|
||||||
|
|
|
@ -96,7 +96,55 @@ static const char* sharedFS =
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
static const char* genericVS =
|
static const char* genericVS_v0 =
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 positionVS = gl_ModelViewMatrix * vec4(gl_Vertex.xyz, 1);\n"
|
||||||
|
" gl_ClipDistance[0] = dot(positionVS, gl_ClipPlane[0]);\n"
|
||||||
|
" gl_Position = ftransform();\n"
|
||||||
|
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
|
||||||
|
" gl_TexCoord[1] = gl_MultiTexCoord1;\n"
|
||||||
|
" gl_TexCoord[2] = gl_Color;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// gl_ClipDistance doesn't have to be redeclared according to the GLSL specs,
|
||||||
|
// but there might some finicky drivers out there
|
||||||
|
static const char* genericVS_v1 =
|
||||||
|
"out varying float gl_ClipDistance[1];\n"
|
||||||
|
"\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 positionVS = gl_ModelViewMatrix * vec4(gl_Vertex.xyz, 1);\n"
|
||||||
|
" gl_ClipDistance[0] = dot(positionVS, gl_ClipPlane[0]);\n"
|
||||||
|
" gl_Position = ftransform();\n"
|
||||||
|
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
|
||||||
|
" gl_TexCoord[1] = gl_MultiTexCoord1;\n"
|
||||||
|
" gl_TexCoord[2] = gl_Color;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// gl_ClipDistance doesn't have to be redeclared according to the GLSL specs,
|
||||||
|
// but there might some finicky drivers out there
|
||||||
|
static const char* genericVS_v2 =
|
||||||
|
"#extension GL_ARB_gpu_shader5 : require\n"
|
||||||
|
"\n"
|
||||||
|
"out gl_PerVertex\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 gl_Position;\n"
|
||||||
|
" vec4 gl_TexCoord[3];\n"
|
||||||
|
" float gl_ClipDistance[1];\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 positionVS = gl_ModelViewMatrix * vec4(gl_Vertex.xyz, 1);\n"
|
||||||
|
" gl_ClipDistance[0] = dot(positionVS, gl_ClipPlane[0]);\n"
|
||||||
|
" gl_Position = ftransform();\n"
|
||||||
|
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
|
||||||
|
" gl_TexCoord[1] = gl_MultiTexCoord1;\n"
|
||||||
|
" gl_TexCoord[2] = gl_Color;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char* genericVS_v3 =
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Position = ftransform();\n"
|
" gl_Position = ftransform();\n"
|
||||||
|
@ -105,6 +153,14 @@ static const char* genericVS =
|
||||||
" gl_TexCoord[2] = gl_Color;\n"
|
" gl_TexCoord[2] = gl_Color;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
static const char* genericVS[] =
|
||||||
|
{
|
||||||
|
genericVS_v0,
|
||||||
|
genericVS_v1,
|
||||||
|
genericVS_v2,
|
||||||
|
genericVS_v3
|
||||||
|
};
|
||||||
|
|
||||||
static const char* genericFS =
|
static const char* genericFS =
|
||||||
"uniform sampler2D texture1;\n"
|
"uniform sampler2D texture1;\n"
|
||||||
"uniform sampler2D texture2;\n"
|
"uniform sampler2D texture2;\n"
|
||||||
|
@ -815,10 +871,21 @@ static qbool GL2_Init()
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !GL2_CreateProgram( genericProg, genericVS, genericFS ) ) {
|
qbool createdGenericVS = qfalse;
|
||||||
ri.Error( PRINT_ERROR, "Failed to compile generic shaders\n" );
|
for ( int i = 0; i < ARRAY_LEN( genericVS ); ++i ) {
|
||||||
|
if ( GL2_CreateProgram( genericProg, genericVS[i], genericFS ) ) {
|
||||||
|
createdGenericVS = qtrue;
|
||||||
|
if ( i == ARRAY_LEN( genericVS ) - 1 ) {
|
||||||
|
ri.Printf( PRINT_WARNING, "Failed to compile generic shader using gl_ClipDistance\n" );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !createdGenericVS ) {
|
||||||
|
ri.Error( PRINT_ERROR, "Failed to compile all variants of the generic shaders\n" );
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
genericProgAttribs.texture1 = glGetUniformLocation( genericProg.p, "texture1" );
|
genericProgAttribs.texture1 = glGetUniformLocation( genericProg.p, "texture1" );
|
||||||
genericProgAttribs.texture2 = glGetUniformLocation( genericProg.p, "texture2" );
|
genericProgAttribs.texture2 = glGetUniformLocation( genericProg.p, "texture2" );
|
||||||
genericProgAttribs.texEnv = glGetUniformLocation( genericProg.p, "texEnv" );
|
genericProgAttribs.texEnv = glGetUniformLocation( genericProg.p, "texEnv" );
|
||||||
|
@ -1309,6 +1376,10 @@ static void GAL_Begin3D()
|
||||||
glClipPlane (GL_CLIP_PLANE0, plane2);
|
glClipPlane (GL_CLIP_PLANE0, plane2);
|
||||||
glEnable (GL_CLIP_PLANE0);
|
glEnable (GL_CLIP_PLANE0);
|
||||||
} else {
|
} else {
|
||||||
|
const double dummyPlane[4] = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
glClipPlane (GL_CLIP_PLANE0, dummyPlane);
|
||||||
glDisable (GL_CLIP_PLANE0);
|
glDisable (GL_CLIP_PLANE0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue