Skip to content

Commit

Permalink
Heretic|Renderer: Added “rend-ring-effect” cvar
Browse files Browse the repository at this point in the history
The values are:
0 = colorize.gold shader (default)
1 = colorize.gold.inverted shader

Changing the value will take effect after the special filter is reinitialized (e.g., map change).
  • Loading branch information
skyjake committed Oct 14, 2018
1 parent 14d36fa commit ceda764
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
Expand Up @@ -53,7 +53,7 @@ fx {
}
}
"
}
}

shader colorize.gold {
vertex $= fx.post.commonVertex
Expand All @@ -78,5 +78,30 @@ fx {
}
"
}

shader colorize.inverted.gold {
vertex $= fx.post.commonVertex
fragment = "
#include '../include/hsv.glsl'
uniform sampler2D uTex;
uniform float uFadeInOut;
in vec2 vUV;

void main(void) {
vec4 original = texture(uTex, vUV);
vec4 colorized = rgbToHsv(original);
colorized.x = 40.0; // Fix hue to gold.
colorized.y = 1.0; // Full saturation.
colorized.z = 1.0 - colorized.z; // Invert value.
colorized = hsvToRgb(colorized);
if (uFadeInOut < 1.0) {
out_FragColor = mix(original, colorized, uFadeInOut);
}
else {
out_FragColor = colorized;
}
}
"
}
}
}
2 changes: 2 additions & 0 deletions doomsday/apps/plugins/common/include/r_special.h
Expand Up @@ -21,6 +21,8 @@

#include <de/libcore.h>

DENG2_EXTERN_C void R_SpecialFilterRegister(void);

DENG2_EXTERN_C void R_InitSpecialFilter(void);

/**
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/plugins/common/src/game/g_game.cpp
Expand Up @@ -359,7 +359,7 @@ void G_CommonPreInit()
IN_ConsoleRegister(); // For the interlude/intermission.
X_Register(); // For the crosshair.
FI_StackRegister(); // For the InFine lib.
R_InitSpecialFilter();
R_SpecialFilterRegister();
#if __JDOOM__ || __JDOOM64__ || __JHERETIC__
XG_Register();
#endif
Expand Down
14 changes: 13 additions & 1 deletion doomsday/apps/plugins/common/src/r_special.cpp
Expand Up @@ -21,6 +21,18 @@

static float appliedFilter[MAXPLAYERS];

#if defined(__JHERETIC__)
static byte ringShader = 0;
#endif

void R_SpecialFilterRegister()
{
#if defined(__JHERETIC__)
C_VAR_BYTE("rend-ring-effect", &ringShader, 0, 0, 1);
#endif
R_InitSpecialFilter();
}

void R_InitSpecialFilter()
{
for(int i = 0; i < MAXPLAYERS; ++i)
Expand Down Expand Up @@ -68,7 +80,7 @@ void R_UpdateSpecialFilterWithTimeDelta(int player, float delta)
#if defined(__JHERETIC__)
{
delta = 0; // not animated
fxName = "colorize.gold";
fxName = (ringShader == 0 ? "colorize.gold" : "colorize.inverted.gold");

const int filter = plr->powers[PT_INVULNERABILITY];
if (!filter)
Expand Down

0 comments on commit ceda764

Please sign in to comment.