Lasers and cursors can be recolored

This commit is contained in:
Local Atticus 2022-04-27 00:09:30 -04:00 committed by nashiora
parent d75982154e
commit 7f3dc98cbf
11 changed files with 75 additions and 8 deletions

View File

@ -18,6 +18,9 @@ local cursorGlowTopImages = {
gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_top_right.png", 0), gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_top_right.png", 0),
} }
local cursorGlowWhite = gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_white.png", 0);
local cursorGlowColor = gfx.CreateSkinImage("gameplay/crit_line/cursor_glow_color.png", 0);
local CRITBAR_W = 1080 local CRITBAR_W = 1080
local CRITBAR_H = 251 local CRITBAR_H = 251
@ -39,6 +42,11 @@ local drawCursors = function (centerX, centerY,cursors)
local cursorX = cursor.pos * (1 / scale) - cursorW / 2; local cursorX = cursor.pos * (1 / scale) - cursorW / 2;
local cursorY = -cursorH / 2; local cursorY = -cursorH / 2;
local glowAlpha = cursor.alpha;
if (i == 1) then glowAlpha = glowAlpha * 0.7; end
local r, g, b = game.GetLaserColor(i);
gfx.ImageRect( gfx.ImageRect(
cursorX, cursorX,
cursorY, cursorY,
@ -54,11 +62,23 @@ local drawCursors = function (centerX, centerY,cursors)
cursorY, cursorY,
cursorW, cursorW,
cursorH, cursorH,
cursorGlowBottomImages[i+1], cursorGlowWhite,
cursor.alpha, glowAlpha,
0 0
); );
gfx.SetImageTint(r, g, b);
gfx.ImageRect(
cursorX,
cursorY,
cursorW,
cursorH,
cursorGlowColor,
glowAlpha,
0
);
gfx.SetImageTint(255, 255, 255);
gfx.ImageRect( gfx.ImageRect(
cursorX, cursorX,
cursorY, cursorY,
@ -74,11 +94,23 @@ local drawCursors = function (centerX, centerY,cursors)
cursorY, cursorY,
cursorW, cursorW,
cursorH, cursorH,
cursorGlowTopImages[i+1], cursorGlowWhite,
cursor.alpha, glowAlpha,
0 0
); );
gfx.SetImageTint(r, g, b);
gfx.ImageRect(
cursorX,
cursorY,
cursorW,
cursorH,
cursorGlowColor,
glowAlpha,
0
);
gfx.SetImageTint(255, 255, 255);
gfx.Restore(); gfx.Restore();
end end
end end

View File

@ -20,10 +20,27 @@ uniform int hitState;
const float laserSize = 1.0675; const float laserSize = 1.0675;
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main() { void main() {
if (laserPart == 1) { if (laserPart == 1) {
target = texture(mainTex, fsTex); target = texture(mainTex, fsTex);
return; return;
} }
@ -40,8 +57,26 @@ void main() {
x += (laserSize / 2); x += (laserSize / 2);
float y = 0.25 * ceil(float(hitState)) + 0.01; float y = 0.25 * ceil(float(hitState)) + 0.01;
vec4 channels = texture(mainTex, vec2(x, y));
float visiblityMultiplier = 1; vec3 baseColor = color.rgb * channels.g;
vec3 baseHsv = rgb2hsv(baseColor);
target = texture(mainTex, vec2(x, y)) * vec4(visiblityMultiplier,visiblityMultiplier,visiblityMultiplier,1); float h = baseHsv.x;
float hilightHue = 0.0;
if (h < 2.0 / 12.0)
hilightHue = 1.0 - smoothstep(0, 1.0 / 12.0, h);
else hilightHue = smoothstep(2.0 / 12.0, 6.0 / 12.0, h);
hilightHue = mod((280.0 / 360.0) + (hilightHue * 140.0 / 360.0), 1.0);
vec3 hilightColor = hsv2rgb(vec3(hilightHue, 1, 1));
baseColor = baseColor * (1.0 - channels.b) + vec3(channels.b);
//hilightColor = hilightColor * channels.r;
vec3 mixedColor = clamp(mix(baseColor, hilightColor, channels.r), 0.0, 1.0);
target = vec4(mixedColor, 1);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 975 B

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
textures/track - Copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB