qglUseProgramObjectARB(0);CHECKGLERROR
}
else
- Con_Printf("permutation%s failed for shader %s, some features may not work properly!\n", permutationname, "glsl/default.glsl");
+ Con_Printf("permutation%s failed for shader %s, some features may not work properly!\n", permutationname, filename);
if (shaderstring)
Mem_Free(shaderstring);
}
memset(r_glsl_permutations, 0, sizeof(r_glsl_permutations));
}
+void R_GLSL_DumpShader_f(void)
+{
+ int i;
+
+ qfile_t *file = FS_Open("glsl/default.glsl", "w", false, false);
+ if(!file)
+ {
+ Con_Printf("failed to write to glsl/default.glsl\n");
+ return;
+ }
+
+ FS_Print(file, "// The engine may define the following macros:\n");
+ FS_Print(file, "// #define VERTEX_SHADER\n// #define GEOMETRY_SHADER\n// #define FRAGMENT_SHADER\n");
+ for (i = 0;permutationinfo[i][0];i++)
+ FS_Printf(file, "// %s", permutationinfo[i][0]);
+ FS_Print(file, "\n");
+ FS_Print(file, builtinshaderstring);
+ FS_Close(file);
+
+ Con_Printf("data/default.glsl written\n");
+}
+
extern rtexture_t *r_shadow_attenuationgradienttexture;
extern rtexture_t *r_shadow_attenuation2dtexture;
extern rtexture_t *r_shadow_attenuation3dtexture;
// fragment shader on features that are not being used
const char *shaderfilename = NULL;
unsigned int permutation = 0;
+ rtexture_t *nmap;
r_glsl_permutation = NULL;
// TODO: implement geometry-shader based shadow volumes someday
if (rsurface.rtlight)
if (r_glsl_permutation->loc_DiffuseScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_DiffuseScale, r_refdef.lightmapintensity * 2.0f);
if (r_glsl_permutation->loc_SpecularScale >= 0) qglUniform1fARB(r_glsl_permutation->loc_SpecularScale, r_refdef.lightmapintensity * specularscale * 2.0f);
}
- if (r_glsl_permutation->loc_Texture_Normal >= 0) R_Mesh_TexBind(0, R_GetTexture(rsurface.texture->currentskinframe->nmap));
+ nmap = rsurface.texture->currentskinframe->nmap;
+ if (gl_lightmaps.integer)
+ nmap = r_texture_blanknormalmap;
+ if (r_glsl_permutation->loc_Texture_Normal >= 0) R_Mesh_TexBind(0, R_GetTexture(nmap));
if (r_glsl_permutation->loc_Texture_Color >= 0) R_Mesh_TexBind(1, R_GetTexture(rsurface.texture->basetexture));
if (r_glsl_permutation->loc_Texture_Gloss >= 0) R_Mesh_TexBind(2, R_GetTexture(rsurface.texture->glosstexture));
//if (r_glsl_permutation->loc_Texture_Cube >= 0 && permutation & SHADERPERMUTATION_MODE_LIGHTSOURCE) R_Mesh_TexBindCubeMap(3, R_GetTexture(rsurface.rtlight->currentcubemap));
r_main_mempool = Mem_AllocPool("Renderer", 0, NULL);
Cmd_AddCommand("r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
+ Cmd_AddCommand("r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
// FIXME: the client should set up r_refdef.fog stuff including the fogmasktable
if (gamemode == GAME_NEHAHRA)
{
{
// use an alternate animation if the entity's frame is not 0,
// and only if the texture has an alternate animation
- if (ent->frame != 0 && t->anim_total[1])
+ if (ent->frame2 != 0 && t->anim_total[1])
t = t->anim_frames[1][(t->anim_total[1] >= 2) ? ((int)(r_refdef.time * 5.0f) % t->anim_total[1]) : 0];
else
t = t->anim_frames[0][(t->anim_total[0] >= 2) ? ((int)(r_refdef.time * 5.0f) % t->anim_total[0]) : 0];
t->specularscale = r_shadow_gloss2intensity.value;
}
+ // lightmaps mode looks bad with dlights using actual texturing, so turn
+ // off the colormap and glossmap, but leave the normalmap on as it still
+ // accurately represents the shading involved
+ if (gl_lightmaps.integer && !(t->currentmaterialflags & MATERIALFLAG_BLENDED))
+ {
+ t->basetexture = r_texture_white;
+ t->specularscale = 0;
+ }
+
t->currentpolygonfactor = r_refdef.polygonfactor;
t->currentpolygonoffset = r_refdef.polygonoffset;
// submodels are biased to avoid z-fighting with world surfaces that they
GL_DepthMask(writedepth);
GL_Color(1,1,1,1);
GL_AlphaTest(false);
+ // use lightmode 0 (fullbright or lightmap) or 2 (model lighting)
+ rsurface.lightmode = ((rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) || rsurface.modeltexcoordlightmap2f != NULL) ? 0 : 2;
R_Mesh_ColorPointer(NULL, 0, 0);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(r_texture_white);
else if (rsurface.texture->currentnumlayers)
{
// write depth for anything we skipped on the depth-only pass earlier
- if (!writedepth && (rsurface.texture->currentmaterialflags & (MATERIALFLAG_BLENDED | MATERIALFLAG_ALPHATEST)))
+ if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
writedepth = true;
GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
GL_PolygonOffset(rsurface.texture->currentpolygonfactor, rsurface.texture->currentpolygonoffset);