Add powered neon wire rendering
This commit is contained in:
parent
cb1b5006b9
commit
17140fe39f
4 changed files with 71 additions and 0 deletions
39
shaders.lua
39
shaders.lua
|
|
@ -89,6 +89,45 @@ goopShader = love.graphics.newShader[[
|
|||
}
|
||||
]]
|
||||
|
||||
-- Wires are drawn as primitives rather than textured sprites, but LÖVE still
|
||||
-- runs this shader over its default white texture. Inactive runs stay visibly
|
||||
-- connected at half brightness; powered runs get a travelling neon shimmer,
|
||||
-- occasional tube-like noise, and a sub-pixel bend rather than a global fade.
|
||||
wireNeonShader = love.graphics.newShader[[
|
||||
extern number wirePower;
|
||||
extern number wireTime;
|
||||
extern number wirePhase;
|
||||
|
||||
float wireHash(vec2 point) {
|
||||
return fract(sin(dot(point, vec2(127.1, 311.7))) * 43758.5453123);
|
||||
}
|
||||
|
||||
vec4 position(mat4 transformProjection, vec4 vertexPosition) {
|
||||
if (wirePower < 0.5) return transformProjection * vertexPosition;
|
||||
|
||||
// Every segment sharing an endpoint receives the same offset, so corners
|
||||
// stay connected while the live current gives the tube a gentle movement.
|
||||
float wave = sin(vertexPosition.x * 0.085 + vertexPosition.y * 0.13 +
|
||||
wireTime * 4.4 + wirePhase * 9.0);
|
||||
float wobble = wave * 0.32;
|
||||
vertexPosition.xy += vec2(wobble, -wobble * 0.55);
|
||||
return transformProjection * vertexPosition;
|
||||
}
|
||||
|
||||
vec4 effect(vec4 color, Image texture, vec2 textureCoords, vec2 screenCoords) {
|
||||
if (wirePower < 0.5) return vec4(color.rgb * 0.50, color.a * 0.72);
|
||||
|
||||
float travel = dot(screenCoords, vec2(0.070, 0.043)) - wireTime * 6.8 + wirePhase * 13.0;
|
||||
float shimmer = sin(travel) * 0.075 + sin(travel * 2.37 + 1.7) * 0.035;
|
||||
vec2 noiseCell = floor(screenCoords * 0.34) + floor(wireTime * 15.0) * vec2(1.0, -1.0);
|
||||
float noise = wireHash(noiseCell + wirePhase);
|
||||
float flicker = max(0.0, noise - 0.82) * 0.32;
|
||||
float brightness = 0.92 + shimmer + flicker;
|
||||
float alpha = 0.84 + shimmer * 0.80 + flicker * 0.55;
|
||||
return vec4(color.rgb * brightness, color.a * alpha);
|
||||
}
|
||||
]]
|
||||
|
||||
function drawGoopySprite(sprite, x, y, scale)
|
||||
local w, h = sprite:getWidth(), sprite:getHeight()
|
||||
local time = love.timer.getTime()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue