cvar_t r_stereo_redblue = {0, "r_stereo_redblue", "0", "red/blue anaglyph stereo glasses (note: most of these glasses are actually red/cyan, try that one too)"};
cvar_t r_stereo_redcyan = {0, "r_stereo_redcyan", "0", "red/cyan anaglyph stereo glasses, the kind given away at drive-in movies like Creature From The Black Lagoon In 3D"};
cvar_t r_stereo_redgreen = {0, "r_stereo_redgreen", "0", "red/green anaglyph stereo glasses (for those who don't mind yellow)"};
+cvar_t r_stereo_desaturate = {0, "r_stereo_desaturate", "0", "when using anaglyph stereo glasses, desaturate the image for less irritation by the given factor"};
cvar_t r_stereo_angle = {0, "r_stereo_angle", "0", "separation angle of eyes (makes the views look different directions, as an example, 90 gives a 90 degree separation where the views are 45 degrees left and 45 degrees right)"};
cvar_t scr_stipple = {0, "scr_stipple", "0", "interlacing-like stippling of the display"};
cvar_t scr_refresh = {0, "scr_refresh", "1", "allows you to completely shut off rendering for benchmarking purposes"};
Cvar_RegisterVariable(&r_stereo_redblue);
Cvar_RegisterVariable(&r_stereo_redcyan);
Cvar_RegisterVariable(&r_stereo_redgreen);
+ Cvar_RegisterVariable(&r_stereo_desaturate);
Cvar_RegisterVariable(&r_stereo_angle);
Cvar_RegisterVariable(&scr_stipple);
Cvar_RegisterVariable(&scr_refresh);
DPSOFTRAST_UNIFORM_ShadowMapMatrixM4,
DPSOFTRAST_UNIFORM_BloomColorSubtract,
DPSOFTRAST_UNIFORM_NormalmapScrollBlend,
+ DPSOFTRAST_UNIFORM_StereoDesaturate,
DPSOFTRAST_UNIFORM_OffsetMapping_LodDistance,
DPSOFTRAST_UNIFORM_OffsetMapping_Bias,
DPSOFTRAST_UNIFORM_TOTAL
int loc_ShadowMapMatrix;
int loc_BloomColorSubtract;
int loc_NormalmapScrollBlend;
+ int loc_StereoDesaturate;
int loc_BounceGridMatrix;
int loc_BounceGridIntensity;
/// uniform block bindings
SHADERSTATICPARM_SHADOWSAMPLER = 10, ///< sampler
SHADERSTATICPARM_CELSHADING = 11, ///< celshading (alternative diffuse and specular math)
SHADERSTATICPARM_CELOUTLINES = 12, ///< celoutline (depth buffer analysis to produce outlines)
- SHADERSTATICPARM_FXAA = 13 ///< fast approximate anti aliasing
+ SHADERSTATICPARM_FXAA = 13, ///< fast approximate anti aliasing
+ SHADERSTATICPARM_STEREODESATURATE = 14, ///< stereo desaturation
+ SHADERSTATICPARM_STEREODESATURATE_REDCYAN = 15 ///< red/cyan stereo desaturation (set in addition to the previous one)
};
-#define SHADERSTATICPARMS_COUNT 14
+#define SHADERSTATICPARMS_COUNT 16
static const char *shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT];
static int shaderstaticparms_count = 0;
if (r_celoutlines.integer)
R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_CELOUTLINES);
+ if (r_stereo_desaturate.value != 0)
+ if (r_stereo_redblue.integer || r_stereo_redcyan.integer || r_stereo_redgreen.integer)
+ {
+ R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_STEREODESATURATE);
+ if (r_stereo_redcyan.integer)
+ R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_STEREODESATURATE_REDCYAN);
+ }
+
return memcmp(r_compileshader_staticparms, r_compileshader_staticparms_save, sizeof(r_compileshader_staticparms)) != 0;
}
R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_CELSHADING, "USECELSHADING");
R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_CELOUTLINES, "USECELOUTLINES");
R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_FXAA, "USEFXAA");
+ R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_STEREODESATURATE, "USESTEREODESATURATE");
+ R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_STEREODESATURATE_REDCYAN, "USESTEREODESATURATE_REDCYAN");
}
/// information about each possible shader permutation
p->loc_ShadowMapMatrix = qglGetUniformLocation(p->program, "ShadowMapMatrix");
p->loc_BloomColorSubtract = qglGetUniformLocation(p->program, "BloomColorSubtract");
p->loc_NormalmapScrollBlend = qglGetUniformLocation(p->program, "NormalmapScrollBlend");
+ p->loc_StereoDesaturate = qglGetUniformLocation(p->program, "StereoDesaturate");
p->loc_BounceGridMatrix = qglGetUniformLocation(p->program, "BounceGridMatrix");
p->loc_BounceGridIntensity = qglGetUniformLocation(p->program, "BounceGridIntensity");
// initialize the samplers to refer to the texture units we use
D3DPSREGISTER_NormalmapScrollBlend = 52,
D3DPSREGISTER_OffsetMapping_LodDistance = 53,
D3DPSREGISTER_OffsetMapping_Bias = 54,
- // next at 54
+ D3DPSREGISTER_StereoDesaturate = 55,
+ // next at 56
}
D3DPSREGISTER_t;
if (mode == SHADERMODE_WATER)
hlslPSSetParameter2f(D3DPSREGISTER_NormalmapScrollBlend, rsurface.texture->r_water_waterscroll[0], rsurface.texture->r_water_waterscroll[1]);
}
+ hlslPSSetParameter1f(D3DPSREGISTER_StereoDesaturate, r_stereo_desaturate.value);
hlslPSSetParameter2f(D3DPSREGISTER_ShadowMap_TextureScale, r_shadow_shadowmap_texturescale[0], r_shadow_shadowmap_texturescale[1]);
hlslPSSetParameter4f(D3DPSREGISTER_ShadowMap_Parameters, r_shadow_shadowmap_parameters[0], r_shadow_shadowmap_parameters[1], r_shadow_shadowmap_parameters[2], r_shadow_shadowmap_parameters[3]);
hlslPSSetParameter3f(D3DPSREGISTER_Color_Glow, rsurface.glowmod[0], rsurface.glowmod[1], rsurface.glowmod[2]);
if (r_glsl_permutation->loc_SpecularPower >= 0) qglUniform1f(r_glsl_permutation->loc_SpecularPower, rsurface.texture->specularpower * (r_shadow_glossexact.integer ? 0.25f : 1.0f) - 1.0f);
if (r_glsl_permutation->loc_NormalmapScrollBlend >= 0) qglUniform2f(r_glsl_permutation->loc_NormalmapScrollBlend, rsurface.texture->r_water_waterscroll[0], rsurface.texture->r_water_waterscroll[1]);
}
+ if (r_glsl_permutation->loc_StereoDesaturate >= 0) qglUniform1f(r_glsl_permutation->loc_StereoDesaturate, r_stereo_desaturate.value);
if (r_glsl_permutation->loc_TexMatrix >= 0) {Matrix4x4_ToArrayFloatGL(&rsurface.texture->currenttexmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_TexMatrix, 1, false, m16f);}
if (r_glsl_permutation->loc_BackgroundTexMatrix >= 0) {Matrix4x4_ToArrayFloatGL(&rsurface.texture->currentbackgroundtexmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_BackgroundTexMatrix, 1, false, m16f);}
if (r_glsl_permutation->loc_ShadowMapMatrix >= 0) {Matrix4x4_ToArrayFloatGL(&r_shadow_shadowmapmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_ShadowMapMatrix, 1, false, m16f);}
DPSOFTRAST_Uniform1f(DPSOFTRAST_UNIFORM_SpecularPower, rsurface.texture->specularpower * (r_shadow_glossexact.integer ? 0.25f : 1.0f) - 1.0f);
DPSOFTRAST_Uniform2f(DPSOFTRAST_UNIFORM_NormalmapScrollBlend, rsurface.texture->r_water_waterscroll[0], rsurface.texture->r_water_waterscroll[1]);
}
+ DPSOFTRAST_Uniform1f(DPSOFTRAST_UNIFORM_StereoDesaturate, r_stereo_desaturate.value);
{Matrix4x4_ToArrayFloatGL(&rsurface.texture->currenttexmatrix, m16f);DPSOFTRAST_UniformMatrix4fv(DPSOFTRAST_UNIFORM_TexMatrixM1, 1, false, m16f);}
{Matrix4x4_ToArrayFloatGL(&rsurface.texture->currentbackgroundtexmatrix, m16f);DPSOFTRAST_UniformMatrix4fv(DPSOFTRAST_UNIFORM_BackgroundTexMatrixM1, 1, false, m16f);}
{Matrix4x4_ToArrayFloatGL(&r_shadow_shadowmapmatrix, m16f);DPSOFTRAST_UniformMatrix4fv(DPSOFTRAST_UNIFORM_ShadowMapMatrixM1, 1, false, m16f);}
extern cvar_t r_stereo_separation;
extern cvar_t r_stereo_angle;
+extern cvar_t r_stereo_redblue;
+extern cvar_t r_stereo_redcyan;
+extern cvar_t r_stereo_redgreen;
+extern cvar_t r_stereo_desaturate;
qboolean R_Stereo_Active(void);
extern int r_stereo_side;
"#ifdef USENORMALMAPSCROLLBLEND\n",
"uniform highp vec2 NormalmapScrollBlend;\n",
"#endif\n",
+"#ifdef USESTEREODESATURATE\n",
+"uniform myhalf StereoDesaturate;\n",
+"#endif\n",
"void main(void)\n",
"{\n",
"#ifdef USEOFFSETMAPPING\n",
" color.rgb = mix(color.rgb, cast_myhalf3(dp_texture2D(Texture_Reflection, ScreenTexCoord)) * ReflectColor.rgb, ReflectColor.a);\n",
"#endif\n",
"\n",
+"#ifdef USESTEREODESATURATE\n",
+"#ifdef USESTEREODESATURATE_REDCYAN\n",
+" // Goal of this transformation:\n",
+" // Keep brightness of R and GB proportional to each other and to\n",
+" // original brightness.\n",
+" // Retain some coloring (keep G-B invariant except for a factor).\n",
+" // Screw sRGB, BT.709 Luma is good enough.\n",
+" color.rgb = mix(color.rgb, cast_myhalf3(\n",
+" 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b,\n",
+" 0.2126 * color.r + 0.7874 * color.g,\n",
+" 0.2126 * color.r + 0.7874 * color.b\n",
+" ), StereoDesaturate);\n",
+"#else\n",
+" // Goal of this transformation:\n",
+" // Keep brightness of R and G (or B) proportional to each other and to\n",
+" // original brightness.\n",
+" // Screw sRGB, BT.709 Luma is good enough.\n",
+" color.rgb = mix(color.rgb, cast_myhalf3(\n",
+" 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b\n",
+" ), StereoDesaturate);\n",
+"#endif\n",
+"#endif\n",
+"\n",
" dp_FragColor = vec4(color);\n",
"}\n",
"#endif // FRAGMENT_SHADER\n",
"uniform float OffsetMapping_Bias : register(c54),\n",
"#endif\n",
"\n",
+"#ifdef USESTEREODESATURATE\n",
+"uniform float StereoDesaturate : register(c55),\n",
+"#endif\n",
+"\n",
"#ifdef USEDEFERREDLIGHTMAP\n",
"uniform half2 PixelToScreenTexCoord : register(c42),\n",
"uniform half3 DeferredMod_Diffuse : register(c12),\n",
" color.rgb = lerp(color.rgb, half3(tex2D(Texture_Reflection, ScreenTexCoord).rgb) * ReflectColor.rgb, ReflectColor.a);\n",
"#endif\n",
"\n",
+"#ifdef USESTEREODESATURATE\n",
+"#ifdef USESTEREODESATURATE_REDCYAN\n",
+" // Goal of this transformation:\n",
+" // Keep brightness of R and GB proportional to each other and to\n",
+" // original brightness.\n",
+" // Retain some coloring (keep G-B invariant except for a factor).\n",
+" // Screw sRGB, BT.709 Luma is good enough.\n",
+" color.rgb = lerp(color.rgb, half3(\n",
+" 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b,\n",
+" 0.2126 * color.r + 0.7874 * color.g,\n",
+" 0.2126 * color.r + 0.7874 * color.b\n",
+" ), StereoDesaturate);\n",
+"#else\n",
+" // Goal of this transformation:\n",
+" // Keep brightness of R and G (or B) proportional to each other and to\n",
+" // original brightness.\n",
+" // Screw sRGB, BT.709 Luma is good enough.\n",
+" color.rgb = lerp(color.rgb, half3(\n",
+" 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b\n",
+" ), StereoDesaturate);\n",
+"#endif\n",
+"#endif\n",
+"\n",
" dp_FragColor = float4(color);\n",
"}\n",
"#endif // FRAGMENT_SHADER\n",