Platform: Added per-wall kernel dithering, cvar gl_kdither 0/1
This commit is contained in:
parent
f3668f8335
commit
d0231eee50
|
@ -7,6 +7,7 @@
|
|||
!!cvardf gl_ldr=1
|
||||
!!cvardf gl_halflambert=1
|
||||
!!cvardf gl_mono=0
|
||||
!!cvardf gl_kdither=0
|
||||
|
||||
!!permu FAKESHADOWS
|
||||
!!cvardf r_glsl_pcf
|
||||
|
@ -102,9 +103,39 @@ varying vec3 light;
|
|||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
#include "sys/pcf.h"
|
||||
|
||||
vec4 kernel_dither(sampler2D targ, vec2 texc)
|
||||
{
|
||||
int x = int(mod(gl_FragCoord.x, 2.0));
|
||||
int y = int(mod(gl_FragCoord.y, 2.0));
|
||||
int index = x + y * 2;
|
||||
vec2 coord_ofs;
|
||||
vec2 size;
|
||||
|
||||
size.x = 1.0 / textureSize(targ, 0).x;
|
||||
size.y = 1.0 / textureSize(targ, 0).y;
|
||||
|
||||
if (index == 0)
|
||||
coord_ofs = vec2(0.25f, 0.0f);
|
||||
else if (index == 1)
|
||||
coord_ofs = vec2(0.50f, 0.75f);
|
||||
else if (index == 2)
|
||||
coord_ofs = vec2(0.75f, 0.50f);
|
||||
else if (index == 3)
|
||||
coord_ofs = vec2(0.00f, 0.25f);
|
||||
|
||||
return texture2D(targ, texc + coord_ofs * size);
|
||||
}
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec4 diffuse_f = texture2D(s_diffuse, tex_c);
|
||||
vec4 diffuse_f;
|
||||
|
||||
if (gl_kdither == 1.0)
|
||||
diffuse_f = kernel_dither(s_diffuse, tex_c);
|
||||
else
|
||||
diffuse_f = texture2D(s_diffuse, tex_c);
|
||||
|
||||
diffuse_f.rgb *= light;
|
||||
|
||||
#ifdef REFLECTCUBE
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
!!permu FOG
|
||||
!!samps 1
|
||||
!!cvardf gl_mono=0
|
||||
!!cvardf gl_kdither=0
|
||||
|
||||
#include "sys/fog.h"
|
||||
#ifdef VERTEX_SHADER
|
||||
|
@ -22,22 +23,52 @@ varying vec2 tc;
|
|||
varying vec4 vc;
|
||||
uniform vec4 e_colourident;
|
||||
uniform vec4 e_vlscale;
|
||||
void main ()
|
||||
{
|
||||
vec4 col = texture2D(s_t0, tc);
|
||||
|
||||
#ifdef MASK
|
||||
if (col.a < float(MASK))
|
||||
discard;
|
||||
#endif
|
||||
vec4 kernel_dither(sampler2D targ, vec2 texc)
|
||||
{
|
||||
int x = int(mod(gl_FragCoord.x, 2.0));
|
||||
int y = int(mod(gl_FragCoord.y, 2.0));
|
||||
int index = x + y * 2;
|
||||
vec2 coord_ofs;
|
||||
vec2 size;
|
||||
|
||||
col = fog4blend(col * vc * e_colourident * e_vlscale);
|
||||
size.x = 1.0 / textureSize(targ, 0).x;
|
||||
size.y = 1.0 / textureSize(targ, 0).y;
|
||||
|
||||
if (gl_mono == 1.0) {
|
||||
float bw = (col.r + col.g + col.b) / 3.0;
|
||||
col.rgb = vec3(bw, bw, bw) * 1.5;
|
||||
if (index == 0)
|
||||
coord_ofs = vec2(0.25f, 0.0f);
|
||||
else if (index == 1)
|
||||
coord_ofs = vec2(0.50f, 0.75f);
|
||||
else if (index == 2)
|
||||
coord_ofs = vec2(0.75f, 0.50f);
|
||||
else if (index == 3)
|
||||
coord_ofs = vec2(0.00f, 0.25f);
|
||||
|
||||
return texture2D(targ, texc + coord_ofs * size);
|
||||
}
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
||||
void main ()
|
||||
{
|
||||
vec4 col;
|
||||
|
||||
// Arrgh, currently the HUD uses this in HL */
|
||||
if (gl_kdither == 1.0)
|
||||
col = texture2D(s_t0, tc);
|
||||
else
|
||||
col = texture2D(s_t0, tc);
|
||||
|
||||
#ifdef MASK
|
||||
if (col.a < float(MASK))
|
||||
discard;
|
||||
#endif
|
||||
|
||||
col = fog4blend(col * vc * e_colourident * e_vlscale);
|
||||
|
||||
if (gl_mono == 1.0) {
|
||||
float bw = (col.r + col.g + col.b) / 3.0;
|
||||
col.rgb = vec3(bw, bw, bw) * 1.5;
|
||||
}
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
!!samps lightmap
|
||||
!!samps =LIGHTSTYLED lightmap1 lightmap2 lightmap3
|
||||
!!cvardf gl_mono=0
|
||||
!!cvardf gl_kdither=0
|
||||
|
||||
#include "sys/defs.h"
|
||||
|
||||
|
@ -75,9 +76,37 @@ varying mat3 invsurface;
|
|||
return lightmaps;
|
||||
}
|
||||
|
||||
vec4 kernel_dither(sampler2D targ, vec2 texc)
|
||||
{
|
||||
int x = int(mod(gl_FragCoord.x, 2.0));
|
||||
int y = int(mod(gl_FragCoord.y, 2.0));
|
||||
int index = x + y * 2;
|
||||
vec2 coord_ofs;
|
||||
vec2 size;
|
||||
|
||||
size.x = 1.0 / textureSize(targ, 0).x;
|
||||
size.y = 1.0 / textureSize(targ, 0).y;
|
||||
|
||||
if (index == 0)
|
||||
coord_ofs = vec2(0.25f, 0.0f);
|
||||
else if (index == 1)
|
||||
coord_ofs = vec2(0.50f, 0.75f);
|
||||
else if (index == 2)
|
||||
coord_ofs = vec2(0.75f, 0.50f);
|
||||
else if (index == 3)
|
||||
coord_ofs = vec2(0.00f, 0.25f);
|
||||
|
||||
return texture2D(targ, texc + coord_ofs * size);
|
||||
}
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
vec4 diffuse_f = texture2D(s_diffuse, tex_c);
|
||||
vec4 diffuse_f;
|
||||
|
||||
if (gl_kdither == 1.0)
|
||||
diffuse_f = kernel_dither(s_diffuse, tex_c);
|
||||
else
|
||||
diffuse_f = texture2D(s_diffuse, tex_c);
|
||||
|
||||
/* get the alphatesting out of the way first */
|
||||
#ifdef MASK
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
!!cvardf r_glsl_pcf
|
||||
!!samps =FAKESHADOWS shadowmap
|
||||
|
||||
!!cvardf dev_skipdiffuse
|
||||
!!cvardf dev_skipnormal
|
||||
|
||||
#include "sys/defs.h"
|
||||
|
||||
varying vec2 tex_c;
|
||||
|
@ -47,9 +50,9 @@ varying vec2 lm1, lm2, lm3;
|
|||
|
||||
void main ( void )
|
||||
{
|
||||
lightmapped_init();
|
||||
tex_c = v_texcoord * 2.5;
|
||||
detail_c = tex_c * 7.5;
|
||||
lm_c = v_lmcoord;
|
||||
vex_color = v_colour;
|
||||
gl_Position = ftetransform();
|
||||
|
||||
|
@ -63,7 +66,22 @@ varying vec2 lm1, lm2, lm3;
|
|||
#include "sys/fog.h"
|
||||
#include "sys/pcf.h"
|
||||
|
||||
vec3 lightmap_fragment (vec3 normal_f)
|
||||
vec3 lightmap_fragment()
|
||||
{
|
||||
vec3 lightmaps;
|
||||
|
||||
#ifdef LIGHTSTYLED
|
||||
lightmaps = texture2D(s_lightmap0, lm0).rgb * e_lmscale[0].rgb;
|
||||
lightmaps += texture2D(s_lightmap1, lm1).rgb * e_lmscale[1].rgb;
|
||||
lightmaps += texture2D(s_lightmap2, lm2).rgb * e_lmscale[2].rgb;
|
||||
lightmaps += texture2D(s_lightmap3, lm3).rgb * e_lmscale[3].rgb;
|
||||
#else
|
||||
lightmaps = texture2D(s_lightmap, lm0).rgb * e_lmscale.rgb;
|
||||
#endif
|
||||
return lightmaps;
|
||||
}
|
||||
|
||||
vec3 lightmap_fragment(vec3 normal_f)
|
||||
{
|
||||
vec3 lightmaps;
|
||||
|
||||
|
@ -80,17 +98,23 @@ varying vec2 lm1, lm2, lm3;
|
|||
|
||||
void main ( void )
|
||||
{
|
||||
vec4 diff1_f = texture2D( s_t0, tex_c);
|
||||
vec4 diff2_f = texture2D( s_t1, tex_c);
|
||||
vec3 lm1_f = texture2D( s_lightmap, lm_c ).rgb * e_lmscale.rgb;
|
||||
vec4 diff1_f = texture2D(s_t0, tex_c);
|
||||
vec4 diff2_f = texture2D(s_t1, tex_c);
|
||||
vec3 norm1_f = normalize(texture2D(s_t4, tex_c).rgb - 0.5);
|
||||
vec3 norm2_f = normalize(texture2D(s_t5, tex_c).rgb - 0.5);
|
||||
|
||||
vec3 d1_f = texture2D(s_t2, detail_c).rgb;
|
||||
vec3 d2_f = texture2D(s_t3, detail_c).rgb;
|
||||
diff1_f.rgb *= d1_f;
|
||||
diff2_f.rgb *= d2_f;
|
||||
|
||||
diff1_f.rgb *= * lightmap_fragment(normal_f);
|
||||
diff2_f.rgb *= * lightmap_fragment(normal_f);
|
||||
if (float(dev_skipnormal) == 1.0) {
|
||||
diff1_f.rgb *= lightmap_fragment();
|
||||
diff2_f.rgb *= lightmap_fragment();
|
||||
} else {
|
||||
diff1_f.rgb *= lightmap_fragment(norm1_f);
|
||||
diff2_f.rgb *= lightmap_fragment(norm2_f);
|
||||
}
|
||||
|
||||
vec3 output_f = mix( diff1_f.rgb, diff2_f.rgb, vex_color.a );
|
||||
|
||||
|
|
|
@ -36,31 +36,6 @@ void main()
|
|||
#endif
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
uniform vec2 e_sourcesize;
|
||||
|
||||
// this is the kernel dithering scheme, but applied to the end framebuffer
|
||||
// like, this really oughta to done on the individual surfaces, but why bother.
|
||||
// it's just for a bit of fun.
|
||||
vec3 p_dither(vec2 position, vec3 col)
|
||||
{
|
||||
int x = int(mod(position.x, 2.0));
|
||||
int y = int(mod(position.y, 2.0));
|
||||
int index = x + y * 2;
|
||||
vec2 coord_ofs;
|
||||
|
||||
if (index == 0)
|
||||
coord_ofs = vec2(0.25f, 0.0f);
|
||||
else if (index == 1)
|
||||
coord_ofs = vec2(0.50f, 0.75f);
|
||||
else if (index == 2)
|
||||
coord_ofs = vec2(0.75f, 0.50f);
|
||||
else if (index == 3)
|
||||
coord_ofs = vec2(0.00f, 0.25f);
|
||||
|
||||
// -0.003 is the distance intensity, all this is whipped up
|
||||
return texture2D(s_screen, texcoord + coord_ofs * -0.003).rgb;
|
||||
}
|
||||
|
||||
// accentuate the gritty lighting
|
||||
vec3 p_gamma(vec3 col)
|
||||
{
|
||||
|
@ -76,9 +51,6 @@ void main(void)
|
|||
vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y);
|
||||
vec3 col = texture2D(s_screen, texcoord).rgb;
|
||||
|
||||
// dither me first
|
||||
col = p_dither(pos, col);
|
||||
|
||||
// mess with gamma
|
||||
col = p_gamma(col);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ seta gl_picmip 0
|
|||
seta gl_polyblend 1
|
||||
seta gl_specular 0
|
||||
seta gl_texture_anisotropic_filtering 0
|
||||
seta gl_kdither 0
|
||||
|
||||
// interpolation
|
||||
seta cl_nolerp 0
|
||||
|
|
|
@ -16,6 +16,7 @@ seta gl_picmip 0
|
|||
seta gl_polyblend 1
|
||||
seta gl_specular 0
|
||||
seta gl_texture_anisotropic_filtering 0
|
||||
seta gl_kdither 0
|
||||
|
||||
// interpolation
|
||||
seta cl_nolerp 0
|
||||
|
|
|
@ -16,6 +16,7 @@ seta gl_picmip 0
|
|||
seta gl_polyblend 1
|
||||
seta gl_specular 0
|
||||
seta gl_texture_anisotropic_filtering 0
|
||||
seta gl_kdither 0
|
||||
|
||||
// interpolation
|
||||
seta cl_nolerp 1
|
||||
|
|
|
@ -16,6 +16,7 @@ seta gl_picmip 0
|
|||
seta gl_polyblend 1
|
||||
seta gl_specular 0
|
||||
seta gl_texture_anisotropic_filtering 0
|
||||
seta gl_kdither 1
|
||||
|
||||
// interpolation
|
||||
seta cl_nolerp 1
|
||||
|
|
|
@ -16,6 +16,7 @@ seta gl_picmip 0
|
|||
seta gl_polyblend 1
|
||||
seta gl_specular 0
|
||||
seta gl_texture_anisotropic_filtering 0
|
||||
seta gl_kdither 0
|
||||
|
||||
// interpolation
|
||||
seta cl_nolerp 0
|
||||
|
|
|
@ -491,7 +491,7 @@ menu_customgame_init(void)
|
|||
customgame_sbMods.SetItemheight(29);
|
||||
customgame_sbMods.SetHeight(289);
|
||||
customgame_sbMods.SetCallback(customgame_sbmods_changed);
|
||||
customgame_sbMods.SetMax(gameinfo_count-1);
|
||||
customgame_sbMods.SetMax(gameinfo_count);
|
||||
Widget_Add(fn_customgame, customgame_sbMods);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ CModList::Draw(void)
|
|||
{
|
||||
int visible;
|
||||
int pos;
|
||||
int g = 0;
|
||||
drawfill([g_menuofs[0] + m_x, g_menuofs[1] + m_y], [m_size[0], m_size[1]],
|
||||
[0,0,0], 1.0f);
|
||||
|
||||
|
@ -59,18 +58,8 @@ CModList::Draw(void)
|
|||
visible = bound(0, visible, gameinfo_count);
|
||||
pos = m_y;
|
||||
|
||||
for (int i = m_scroll; i < (visible + m_scroll); i++) {
|
||||
for (int i = m_scroll; i <= (visible + m_scroll); i++) {
|
||||
vector colo;
|
||||
g = i;
|
||||
|
||||
/* seperate counter so we skip our current game */
|
||||
if (games[g].gamedir == GAME_DIR) {
|
||||
g++;
|
||||
}
|
||||
|
||||
if (g >= (visible + m_scroll))
|
||||
break;
|
||||
|
||||
if (m_selected == i) {
|
||||
colo = ML_COL_2;
|
||||
drawfill([g_menuofs[0] + m_x, g_menuofs[1] + pos], [m_size[0], 29],
|
||||
|
@ -79,33 +68,33 @@ CModList::Draw(void)
|
|||
colo = ML_COL_1;
|
||||
}
|
||||
|
||||
if (games[g].type != "") {
|
||||
if (games[i].type != "") {
|
||||
drawsetcliparea(g_menuofs[0] + m_x + 2, g_menuofs[1] + pos + 3, 50,30);
|
||||
WLabel_Static(m_x + 2, pos + 3, games[g].type,
|
||||
WLabel_Static(m_x + 2, pos + 3, games[i].type,
|
||||
11, 11, colo, 1.0f, 0, font_arial);
|
||||
drawresetcliparea();
|
||||
}
|
||||
|
||||
/* Game */
|
||||
drawsetcliparea(g_menuofs[0] + m_x + 57, g_menuofs[1] + pos + 3, 112,30);
|
||||
WLabel_Static(m_x + 57, pos + 3, games[g].game, 11, 11, colo,
|
||||
WLabel_Static(m_x + 57, pos + 3, games[i].game, 11, 11, colo,
|
||||
1.0f, 0, font_arial);
|
||||
drawresetcliparea();
|
||||
/* URL */
|
||||
WLabel_Static(m_x + 2, pos + 18, sprintf("Info: %s", games[g].url_info), 11, 11, ML_COL_4,
|
||||
WLabel_Static(m_x + 2, pos + 18, sprintf("Info: %s", games[i].url_info), 11, 11, ML_COL_4,
|
||||
1.0f, 0, font_arial);
|
||||
/* Version */
|
||||
WLabel_Static(m_x + 177, pos + 3, games[g].version, 11, 11, colo,
|
||||
WLabel_Static(m_x + 177, pos + 3, games[i].version, 11, 11, colo,
|
||||
1.0f, 0, font_arial);
|
||||
/* Size */
|
||||
float size = games[g].size / 1024000;
|
||||
float size = games[i].size / 1024000;
|
||||
WLabel_Static(m_x + 227, pos + 3, sprintf("%.1fmb", size), 11, 11, colo,
|
||||
1.0f, 0, font_arial);
|
||||
/* Rating */
|
||||
WLabel_Static(m_x + 277, pos + 3, "0.0", 11, 11, colo,
|
||||
1.0f, 0, font_arial);
|
||||
|
||||
if (games[g].installed == 1) {
|
||||
if (games[i].installed == 1) {
|
||||
/* Installed */
|
||||
WLabel_Static(m_x + 327, pos + 3, "Yes", 11, 11, ML_COL_3,
|
||||
1.0f, 0, font_arial);
|
||||
|
@ -128,7 +117,6 @@ CModList::Draw(void)
|
|||
}
|
||||
|
||||
pos += 29;
|
||||
g++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +125,6 @@ CModList::Input(float type, float x, float y, float devid)
|
|||
{
|
||||
int visible;
|
||||
int pos[2];
|
||||
int g = 0;
|
||||
|
||||
visible = floor(m_size[1] / 29);
|
||||
visible = bound(0, visible, gameinfo_count);
|
||||
|
@ -145,25 +132,16 @@ CModList::Input(float type, float x, float y, float devid)
|
|||
pos[0] = m_x;
|
||||
pos[1] = m_y;
|
||||
|
||||
for (int i = m_scroll; i < (visible + m_scroll); i++) {
|
||||
g = i;
|
||||
|
||||
if (games[g].gamedir == GAME_DIR)
|
||||
g++;
|
||||
|
||||
if (g >= (visible + m_scroll))
|
||||
break;
|
||||
|
||||
for (int i = m_scroll; i <= (visible + m_scroll); i++) {
|
||||
if (Util_CheckMouse(pos[0], pos[1], m_size[0], 29)) {
|
||||
if (type == IE_KEYDOWN) {
|
||||
if (x == K_MOUSE1) {
|
||||
SetSelected(g);
|
||||
SetSelected(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pos[1] += 29;
|
||||
g++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue