diff --git a/source/r_alias.c b/source/r_alias.c index f3231dd..4aafad5 100644 --- a/source/r_alias.c +++ b/source/r_alias.c @@ -80,6 +80,7 @@ static GLuint fullbrightTexLoc; static GLuint useFullbrightTexLoc; static GLuint useOverbrightLoc; static GLuint useAlphaTestLoc; +static GLuint useRFullbrightLoc; #define pose1VertexAttrIndex 0 #define pose1NormalAttrIndex 1 @@ -131,68 +132,78 @@ void GLAlias_CreateShaders(void) { "Pose2Normal", pose2NormalAttrIndex } }; - const GLchar *vertSource = \ - "#version 110\n" - "\n" - "uniform float Blend;\n" - "uniform vec3 ShadeVector;\n" - "uniform vec4 LightColor;\n" - "attribute vec4 TexCoords; // only xy are used \n" - "attribute vec4 Pose1Vert;\n" - "attribute vec3 Pose1Normal;\n" - "attribute vec4 Pose2Vert;\n" - "attribute vec3 Pose2Normal;\n" - "\n" - "varying float FogFragCoord;\n" - "\n" - "float r_avertexnormal_dot(vec3 vertexnormal) // from MH \n" - "{\n" - " float dot = dot(vertexnormal, ShadeVector);\n" - " // wtf - this reproduces anorm_dots within as reasonable a degree of tolerance as the >= 0 case\n" - " if (dot < 0.0)\n" - " return 1.0 + dot * (13.0 / 44.0);\n" - " else\n" - " return 1.0 + dot;\n" - "}\n" - "void main()\n" - "{\n" - " gl_TexCoord[0] = TexCoords;\n" - " vec4 lerpedVert = mix(vec4(Pose1Vert.xyz, 1.0), vec4(Pose2Vert.xyz, 1.0), Blend);\n" - " gl_Position = gl_ModelViewProjectionMatrix * lerpedVert;\n" - " FogFragCoord = gl_Position.w;\n" - " float dot1 = r_avertexnormal_dot(Pose1Normal);\n" - " float dot2 = r_avertexnormal_dot(Pose2Normal);\n" - " gl_FrontColor = LightColor * vec4(vec3(mix(dot1, dot2, Blend)), 1.0);\n" - "}\n"; + const GLchar *vertSource = + "#version 130\n" + "\n" + "uniform float Blend;\n" + "uniform vec3 ShadeVector;\n" + "uniform vec4 LightColor;\n" + "attribute vec4 TexCoords; // only xy are used \n" + "attribute vec4 Pose1Vert;\n" + "attribute vec3 Pose1Normal;\n" + "attribute vec4 Pose2Vert;\n" + "attribute vec3 Pose2Normal;\n" + "\n" + "varying float FogFragCoord;\n" + "\n" + "float r_avertexnormal_dot(vec3 vertexnormal) // from MH \n" + "{\n" + " float dot = dot(vertexnormal, ShadeVector);\n" + " // wtf - this reproduces anorm_dots within as reasonable a degree of tolerance as the >= 0 case\n" + " if(dot < 0.0)\n" + " return 1.0 + dot * (13.0 / 44.0);\n" + " else\n" + " return 1.0 + dot;\n" + "}\n" + "\n" + "void main()\n" + "{\n" + " gl_TexCoord[0] = TexCoords;\n" + " vec4 lerpedVert = mix(vec4(Pose1Vert.xyz, 1.0), vec4(Pose2Vert.xyz, 1.0), Blend);\n" + " gl_Position = gl_ModelViewProjectionMatrix * lerpedVert;\n" + " gl_Position = vec4(floor(gl_Position.xyz * 10.0) / 10.0, gl_Position.w);" + " gl_Position /= abs(gl_Position.w);\n" + " FogFragCoord = gl_Position.w;\n" + " float dot1 = r_avertexnormal_dot(Pose1Normal);\n" + " float dot2 = r_avertexnormal_dot(Pose2Normal);\n" + " gl_FrontColor = LightColor * vec4(vec3(mix(dot1, dot2, Blend)), 1.0);\n" + "}\n"; const GLchar *fragSource = \ - "#version 110\n" - "\n" - "uniform sampler2D Tex;\n" - "uniform sampler2D FullbrightTex;\n" - "uniform bool UseFullbrightTex;\n" - "uniform bool UseOverbright;\n" - "uniform bool UseAlphaTest;\n" - "\n" - "varying float FogFragCoord;\n" - "\n" - "void main()\n" - "{\n" - " vec4 result = texture2D(Tex, gl_TexCoord[0].xy);\n" - " if (UseAlphaTest && (result.a < 0.666))\n" - " discard;\n" - " result *= gl_Color;\n" - " if (UseOverbright)\n" - " result.rgb *= 2.0;\n" - " if (UseFullbrightTex)\n" - " result += texture2D(FullbrightTex, gl_TexCoord[0].xy);\n" - " result = clamp(result, 0.0, 1.0);\n" - " float fog = exp(-gl_Fog.density * gl_Fog.density * FogFragCoord * FogFragCoord);\n" - " fog = clamp(fog, 0.0, 1.0);\n" - " result = mix(gl_Fog.color, result, fog);\n" - " result.a = gl_Color.a;\n" // FIXME: This will make almost transparent things cut holes though heavy fog - " gl_FragColor = result;\n" - "}\n"; + "#version 130\n" + "\n" + "uniform sampler2D Tex;\n" + "uniform sampler2D FullbrightTex;\n" + "uniform bool UseFullbrightTex;\n" + "uniform bool UseOverbright;\n" + "uniform bool UseAlphaTest;\n" + "uniform bool UseRFullbright;\n" + "\n" + "varying float FogFragCoord;\n" + "\n" + "void main()\n" + "{\n" + " vec4 result = texture2D(Tex, gl_TexCoord[0].xy);\n" + " if(UseAlphaTest && result.a < 0.666)\n" + " discard;\n" + " if(!UseRFullbright)\n" + " {\n" + " result *= gl_Color;\n" + " if(UseOverbright)\n" + " result.rgb *= 2.0;\n" + " }\n" + " if(UseFullbrightTex)\n" + " result += texture2D(FullbrightTex, gl_TexCoord[0].xy);\n" + " result = clamp(result, 0.0, 1.0);\n" + " if(!UseRFullbright)\n" + " {\n" + " float fog = exp(-gl_Fog.density * gl_Fog.density * FogFragCoord * FogFragCoord);\n" + " fog = clamp(fog, 0.0, 1.0);\n" + " result = mix(gl_Fog.color, result, fog);\n" + " result.a = gl_Color.a;\n" // FIXME: This will make almost transparent things cut holes though heavy fog + " }\n" + " gl_FragColor = result;\n" + "}\n"; if(!gl_glsl_alias_able) return; @@ -210,6 +221,7 @@ void GLAlias_CreateShaders(void) useFullbrightTexLoc = GL_GetUniformLocation(&r_alias_program, "UseFullbrightTex"); useOverbrightLoc = GL_GetUniformLocation(&r_alias_program, "UseOverbright"); useAlphaTestLoc = GL_GetUniformLocation(&r_alias_program, "UseAlphaTest"); + useRFullbrightLoc = GL_GetUniformLocation(&r_alias_program, "UseRFullbright"); } } @@ -267,6 +279,7 @@ void GL_DrawAliasFrame_GLSL(aliashdr_t *paliashdr, lerpdata_t lerpdata, gltextur GL_Uniform1iFunc(useFullbrightTexLoc, (fb != NULL) ? 1 : 0); GL_Uniform1fFunc(useOverbrightLoc, overbright ? 1 : 0); GL_Uniform1iFunc(useAlphaTestLoc, (currententity->model->flags & MF_HOLEY) ? 1 : 0); + GL_Uniform1iFunc(useRFullbrightLoc, r_fullbright_cheatsafe); // set textures GL_SelectTexture(GL_TEXTURE0); @@ -714,6 +727,8 @@ void R_DrawAliasModel(entity_t *e) // // draw it // + // call fast path if possible. if the shader compliation failed for some reason, + // r_alias_program will be 0. if(r_drawflat_cheatsafe) { glDisable(GL_TEXTURE_2D); @@ -721,6 +736,10 @@ void R_DrawAliasModel(entity_t *e) glEnable(GL_TEXTURE_2D); srand((int32_t)(cl.time * 1000)); //restore randomness } + else if(r_alias_program != 0) + { + GL_DrawAliasFrame_GLSL(paliashdr, lerpdata, tx, fb); + } else if(r_fullbright_cheatsafe) { GL_Bind(tx); @@ -751,12 +770,6 @@ void R_DrawAliasModel(entity_t *e) GL_DrawAliasFrame(paliashdr, lerpdata); glEnable(GL_TEXTURE_2D); } -// call fast path if possible. if the shader compliation failed for some reason, -// r_alias_program will be 0. - else if(r_alias_program != 0) - { - GL_DrawAliasFrame_GLSL(paliashdr, lerpdata, tx, fb); - } else if(overbright) { if(gl_texture_env_combine && gl_mtexable && gl_texture_env_add && fb) //case 1: everything in one pass diff --git a/source/r_world.c b/source/r_world.c index 33b56ce..9962308 100644 --- a/source/r_world.c +++ b/source/r_world.c @@ -815,52 +815,52 @@ void GLWorld_CreateShaders(void) }; const GLchar *vertSource = \ - "#version 110\n" - "\n" - "attribute vec3 Vert;\n" - "attribute vec2 TexCoords;\n" - "attribute vec2 LMCoords;\n" - "\n" - "varying float FogFragCoord;\n" - "\n" - "void main()\n" - "{\n" - " gl_TexCoord[0] = vec4(TexCoords, 0.0, 0.0);\n" - " gl_TexCoord[1] = vec4(LMCoords, 0.0, 0.0);\n" - " gl_Position = gl_ModelViewProjectionMatrix * vec4(Vert, 1.0);\n" - " FogFragCoord = gl_Position.w;\n" - "}\n"; + "#version 130\n" + "\n" + "attribute vec3 Vert;\n" + "attribute vec2 TexCoords;\n" + "attribute vec2 LMCoords;\n" + "\n" + "varying float FogFragCoord;\n" + "\n" + "void main()\n" + "{\n" + " gl_TexCoord[0] = vec4(TexCoords, 0.0, 0.0);\n" + " gl_TexCoord[1] = vec4(LMCoords, 0.0, 0.0);\n" + " gl_Position = gl_ModelViewProjectionMatrix * vec4(Vert, 1.0);\n" + " FogFragCoord = gl_Position.w;\n" + "}\n"; const GLchar *fragSource = \ - "#version 110\n" - "\n" - "uniform sampler2D Tex;\n" - "uniform sampler2D LMTex;\n" - "uniform sampler2D FullbrightTex;\n" - "uniform bool UseFullbrightTex;\n" - "uniform bool UseOverbright;\n" - "uniform bool UseAlphaTest;\n" - "uniform float Alpha;\n" - "\n" - "varying float FogFragCoord;\n" - "\n" - "void main()\n" - "{\n" - " vec4 result = texture2D(Tex, gl_TexCoord[0].xy);\n" - " if (UseAlphaTest && (result.a < 0.666))\n" - " discard;\n" - " result *= texture2D(LMTex, gl_TexCoord[1].xy);\n" - " if (UseOverbright)\n" - " result.rgb *= 2.0;\n" - " if (UseFullbrightTex)\n" - " result += texture2D(FullbrightTex, gl_TexCoord[0].xy);\n" - " result = clamp(result, 0.0, 1.0);\n" - " float fog = exp(-gl_Fog.density * gl_Fog.density * FogFragCoord * FogFragCoord);\n" - " fog = clamp(fog, 0.0, 1.0);\n" - " result = mix(gl_Fog.color, result, fog);\n" - " result.a = Alpha;\n" // FIXME: This will make almost transparent things cut holes though heavy fog - " gl_FragColor = result;\n" - "}\n"; + "#version 130\n" + "\n" + "uniform sampler2D Tex;\n" + "uniform sampler2D LMTex;\n" + "uniform sampler2D FullbrightTex;\n" + "uniform bool UseFullbrightTex;\n" + "uniform bool UseOverbright;\n" + "uniform bool UseAlphaTest;\n" + "uniform float Alpha;\n" + "\n" + "varying float FogFragCoord;\n" + "\n" + "void main()\n" + "{\n" + " vec4 result = texture2D(Tex, gl_TexCoord[0].xy);\n" + " if (UseAlphaTest && (result.a < 0.666))\n" + " discard;\n" + " result *= texture2D(LMTex, gl_TexCoord[1].xy);\n" + " if (UseOverbright)\n" + " result.rgb *= 2.0;\n" + " if (UseFullbrightTex)\n" + " result += texture2D(FullbrightTex, gl_TexCoord[0].xy);\n" + " result = clamp(result, 0.0, 1.0);\n" + " float fog = exp(-gl_Fog.density * gl_Fog.density * FogFragCoord * FogFragCoord);\n" + " fog = clamp(fog, 0.0, 1.0);\n" + " result = mix(gl_Fog.color, result, fog);\n" + " result.a = Alpha;\n" // FIXME: This will make almost transparent things cut holes though heavy fog + " gl_FragColor = result;\n" + "}\n"; if(!gl_glsl_alias_able) return;