SHADERPERMUTATION_OFFSETMAPPING = 1<<16, ///< adjust texcoords to roughly simulate a displacement mapped surface
SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING = 1<<17, ///< adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!)
SHADERPERMUTATION_SHADOWMAP2D = 1<<18, ///< (lightsource) use shadowmap texture as light filter
- SHADERPERMUTATION_SHADOWMAPPCF = 1<<19, ///< (lightsource) use percentage closer filtering on shadowmap test results
- SHADERPERMUTATION_SHADOWMAPPCF2 = 1<<20, ///< (lightsource) use higher quality percentage closer filtering on shadowmap test results
- SHADERPERMUTATION_SHADOWSAMPLER = 1<<21, ///< (lightsource) use hardware shadowmap test
- SHADERPERMUTATION_SHADOWMAPVSDCT = 1<<22, ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing
- SHADERPERMUTATION_SHADOWMAPORTHO = 1<<23, ///< (lightsource) use orthographic shadowmap projection
- SHADERPERMUTATION_DEFERREDLIGHTMAP = 1<<24, ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
- SHADERPERMUTATION_ALPHAKILL = 1<<25, ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5
- SHADERPERMUTATION_REFLECTCUBE = 1<<26, ///< fake reflections using global cubemap (not HDRI light probe)
- SHADERPERMUTATION_NORMALMAPSCROLLBLEND = 1<<27, ///< (water) counter-direction normalmaps scrolling
- SHADERPERMUTATION_BOUNCEGRID = 1<<28, ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light
- SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL = 1<<29, ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component
- SHADERPERMUTATION_TRIPPY = 1<<30, ///< use trippy vertex shader effect
- SHADERPERMUTATION_DEPTHRGB = 1<<31, ///< read/write depth values in RGB color coded format for older hardware without depth samplers
- SHADERPERMUTATION_COUNT = 32 ///< size of shaderpermutationinfo array
+ SHADERPERMUTATION_SHADOWMAPVSDCT = 1<<19, ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing
+ SHADERPERMUTATION_SHADOWMAPORTHO = 1<<20, ///< (lightsource) use orthographic shadowmap projection
+ SHADERPERMUTATION_DEFERREDLIGHTMAP = 1<<21, ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
+ SHADERPERMUTATION_ALPHAKILL = 1<<22, ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5
+ SHADERPERMUTATION_REFLECTCUBE = 1<<23, ///< fake reflections using global cubemap (not HDRI light probe)
+ SHADERPERMUTATION_NORMALMAPSCROLLBLEND = 1<<24, ///< (water) counter-direction normalmaps scrolling
+ SHADERPERMUTATION_BOUNCEGRID = 1<<25, ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light
+ SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL = 1<<26, ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component
+ SHADERPERMUTATION_TRIPPY = 1<<27, ///< use trippy vertex shader effect
+ SHADERPERMUTATION_DEPTHRGB = 1<<28, ///< read/write depth values in RGB color coded format for older hardware without depth samplers
+ SHADERPERMUTATION_COUNT = 29 ///< size of shaderpermutationinfo array
}
shaderpermutation_t;
{"#define USEOFFSETMAPPING\n", " offsetmapping"},
{"#define USEOFFSETMAPPING_RELIEFMAPPING\n", " reliefmapping"},
{"#define USESHADOWMAP2D\n", " shadowmap2d"},
- {"#define USESHADOWMAPPCF 1\n", " shadowmappcf"}, // TODO make this a static parm
- {"#define USESHADOWMAPPCF 2\n", " shadowmappcf2"}, // TODO make this a static parm
- {"#define USESHADOWSAMPLER\n", " shadowsampler"}, // TODO make this a static parm
{"#define USESHADOWMAPVSDCT\n", " shadowmapvsdct"}, // TODO make this a static parm
{"#define USESHADOWMAPORTHO\n", " shadowmaportho"},
{"#define USEDEFERREDLIGHTMAP\n", " deferredlightmap"},
SHADERSTATICPARM_POSTPROCESS_USERVEC4 = 5, ///< postprocess uservec4 is enabled
SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS = 6, // use both alpha layers while blending materials, allows more advanced microblending
SHADERSTATICPARM_OFFSETMAPPING_USELOD = 7, ///< LOD for offsetmapping
+ SHADERSTATICPARM_SHADOWMAPPCF_1 = 8, ///< PCF 1
+ SHADERSTATICPARM_SHADOWMAPPCF_2 = 9, ///< PCF 2
+ SHADERSTATICPARM_SHADOWSAMPLER = 10, ///< sampler
};
-#define SHADERSTATICPARMS_COUNT 8
+#define SHADERSTATICPARMS_COUNT 11
static const char *shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT];
static int shaderstaticparms_count = 0;
static unsigned int r_compileshader_staticparms[(SHADERSTATICPARMS_COUNT + 0x1F) >> 5] = {0};
#define R_COMPILESHADER_STATICPARM_ENABLE(p) r_compileshader_staticparms[(p) >> 5] |= (1 << ((p) & 0x1F))
-static qboolean R_CompileShader_CheckStaticParms(void)
+
+extern qboolean r_shadow_shadowmapsampler;
+extern int r_shadow_shadowmappcf;
+qboolean R_CompileShader_CheckStaticParms(void)
{
static int r_compileshader_staticparms_save[1];
memcpy(r_compileshader_staticparms_save, r_compileshader_staticparms, sizeof(r_compileshader_staticparms));
}
if (r_glsl_offsetmapping_lod.integer && r_glsl_offsetmapping_lod_distance.integer > 0)
R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_OFFSETMAPPING_USELOD);
+
+ if (r_shadow_shadowmapsampler)
+ R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_SHADOWSAMPLER);
+ if (r_shadow_shadowmappcf > 1)
+ R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_SHADOWMAPPCF_2);
+ else if (r_shadow_shadowmappcf)
+ R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_SHADOWMAPPCF_1);
+
return memcmp(r_compileshader_staticparms, r_compileshader_staticparms_save, sizeof(r_compileshader_staticparms)) != 0;
}
R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_POSTPROCESS_USERVEC4, "USERVEC4");
R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS, "USEBOTHALPHAS");
R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_OFFSETMAPPING_USELOD, "USEOFFSETMAPPING_LOD");
+ R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_SHADOWMAPPCF_1, "USESHADOWMAPPCF 1");
+ R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_SHADOWMAPPCF_2, "USESHADOWMAPPCF 2");
+ R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_SHADOWSAMPLER, "USESHADOWSAMPLER");
}
/// information about each possible shader permutation
DPSOFTRAST_Uniform1f(DPSOFTRAST_UNIFORM_ClientTime, cl.time);
}
-static void R_GLSL_Restart_f(void)
+void R_GLSL_Restart_f(void)
{
unsigned int i, limit;
if (glslshaderstring && glslshaderstring != builtinshaderstring)
extern float r_shadow_shadowmap_texturescale[2];
extern float r_shadow_shadowmap_parameters[4];
extern qboolean r_shadow_shadowmapvsdct;
-extern qboolean r_shadow_shadowmapsampler;
-extern int r_shadow_shadowmappcf;
extern rtexture_t *r_shadow_shadowmap2ddepthbuffer;
extern rtexture_t *r_shadow_shadowmap2ddepthtexture;
extern rtexture_t *r_shadow_shadowmapvsdcttexture;
if(r_shadow_shadowmapvsdct)
permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
- if (r_shadow_shadowmapsampler)
- permutation |= SHADERPERMUTATION_SHADOWSAMPLER;
- if (r_shadow_shadowmappcf > 1)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF2;
- else if (r_shadow_shadowmappcf)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
if (r_shadow_shadowmap2ddepthbuffer)
permutation |= SHADERPERMUTATION_DEPTHRGB;
}
permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
permutation |= SHADERPERMUTATION_SHADOWMAP2D;
- if (r_shadow_shadowmapsampler)
- permutation |= SHADERPERMUTATION_SHADOWSAMPLER;
- if (r_shadow_shadowmappcf > 1)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF2;
- else if (r_shadow_shadowmappcf)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
if (r_shadow_shadowmap2ddepthbuffer)
permutation |= SHADERPERMUTATION_DEPTHRGB;
}
permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
permutation |= SHADERPERMUTATION_SHADOWMAP2D;
- if (r_shadow_shadowmapsampler)
- permutation |= SHADERPERMUTATION_SHADOWSAMPLER;
- if (r_shadow_shadowmappcf > 1)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF2;
- else if (r_shadow_shadowmappcf)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
if (r_shadow_shadowmap2ddepthbuffer)
permutation |= SHADERPERMUTATION_DEPTHRGB;
}
permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
permutation |= SHADERPERMUTATION_SHADOWMAP2D;
- if (r_shadow_shadowmapsampler)
- permutation |= SHADERPERMUTATION_SHADOWSAMPLER;
- if (r_shadow_shadowmappcf > 1)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF2;
- else if (r_shadow_shadowmappcf)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
if (r_shadow_shadowmap2ddepthbuffer)
permutation |= SHADERPERMUTATION_DEPTHRGB;
}
permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
permutation |= SHADERPERMUTATION_SHADOWMAP2D;
- if (r_shadow_shadowmapsampler)
- permutation |= SHADERPERMUTATION_SHADOWSAMPLER;
- if (r_shadow_shadowmappcf > 1)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF2;
- else if (r_shadow_shadowmappcf)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
if (r_shadow_shadowmap2ddepthbuffer)
permutation |= SHADERPERMUTATION_DEPTHRGB;
}
if (r_shadow_shadowmapvsdct)
permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
- if (r_shadow_shadowmapsampler)
- permutation |= SHADERPERMUTATION_SHADOWSAMPLER;
- if (r_shadow_shadowmappcf > 1)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF2;
- else if (r_shadow_shadowmappcf)
- permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
if (r_shadow_shadowmap2ddepthbuffer)
permutation |= SHADERPERMUTATION_DEPTHRGB;
}