Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions assets/shaders/brimstone_badge.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#endif

extern MY_HIGHP_OR_MEDIUMP vec2 brimstone_badge;
extern MY_HIGHP_OR_MEDIUMP number time;
extern MY_HIGHP_OR_MEDIUMP vec2 uibox_pos;
extern MY_HIGHP_OR_MEDIUMP vec2 uibox_size;
extern MY_HIGHP_OR_MEDIUMP float screen_scale;

number hue(number s, number t, number h)
{
Expand Down Expand Up @@ -92,12 +90,11 @@ vec4 effect( vec4 colour, Image texture, vec2 texture_coords, vec2 screen_coords
{
vec4 tex = colour;

vec2 uv = (screen_coords - uibox_pos) / uibox_size.xy;

vec2 uv = (screen_coords - uibox_pos) / (uibox_size.xy * screen_scale);
if (uv.x < 0.00001) {
uv = (screen_coords - (uibox_pos / screen_scale)) / (uibox_size.xy * screen_scale);
}

//if (uv.x < 0.00001) {
// uv = (screen_coords - (uibox_pos / screen_scale)) / (uibox_size.xy * screen_scale);
//}

uv.x = uv.x * (love_ScreenSize.x/love_ScreenSize.y);
uv.y = uv.y / (20.);
Expand All @@ -106,7 +103,7 @@ vec4 effect( vec4 colour, Image texture, vec2 texture_coords, vec2 screen_coords

//float fuckyouGSL = min(0, 0.001 * (brimstone_badge.x + uibox_size.x + uibox_pos.x + screen_scale + time));

float t = time + brimstone_badge.y * 0.32151;
float t = 1543.1954 + brimstone_badge.y * 0.32151;

float scale_const = 10;

Expand Down
69 changes: 36 additions & 33 deletions lovely/uibox_shader.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dump_lua = true
priority = 1

# UI Element Shader Patch by InvalidOS
# v2.0.1a
# v2.0.2
# play lemniscate (when it releases) (it is not released yet)

## hacky method of preventing repeat patches
Expand All @@ -18,8 +18,8 @@ position = "at"
payload = '''-- [ THE PATCH WAS USED UP ]''' # haha funny deltarune reference
match_indent = true

## UIBox shader
## UIElement:draw_self()
## UIBox shaders
## UIElement:draw_pixellated_rect()
[[patches]]
[patches.pattern]
target = "engine/ui.lua"
Expand All @@ -32,36 +32,22 @@ payload = '''
love.graphics.polygon((_type == 'line' or _type == 'line_emboss') and 'line' or "fill", self.pixellated_rect[_type].vertices)
end

local function to_screenspace()
local T = self.CT or self.T
self.ARGS.collides_with_point_translation = self.ARGS.collides_with_point_translation or {}
self.ARGS.collides_with_point_rotation = self.ARGS.collides_with_point_rotation or {}
local _t = self.ARGS.collides_with_point_translation
local _r = self.ARGS.collides_with_point_rotation
if self.container ~= self then
_t.x, _t.y = self.container.T.w/2, self.container.T.h/2
point_translate(T, _t)
_t.x, _t.y = -self.container.T.w/2+self.container.T.x, -self.container.T.h/2+self.container.T.y
point_translate(T, _t)
T.x = T.x * G.TILESCALE*G.TILESIZE*G.CANV_SCALE
T.y = T.y * G.TILESCALE*G.TILESIZE*G.CANV_SCALE
end
return T
end

local function _draw_layer(shader, send)
local args = {
G.TIMERS.REAL/28,
G.TIMERS.REAL
}

if send then
if shader == "none" or shader == "dissolve" then
_draw()
return
elseif send then
for k, v in ipairs(send) do
local val = v.val or (v.func and v.func(self))

-- thanks talisman
if Entropy.is_big(val) then
if to_big(val) > to_big(1e300) then
if Talisman and type(val) == "table" and is_number(val) then
if val > to_big(1e300) then
val = 1e300
else
val = val:tonumber()
Expand All @@ -73,18 +59,19 @@ payload = '''
elseif shader == "vortex" then
G.SHADERS['vortex']:send('vortex_amt', G.TIMERS.REAL - (G.vortex_time or 0))
else
local screen_pos = to_screenspace(self)
local prefix = SMODS.Shaders[shader] and SMODS.Shaders[shader].mod and SMODS.Shaders[shader].mod.prefix
local prefixless_key = prefix and string.sub(shader, #prefix + 2) or shader

local tile_scale = G.TILESCALE*G.TILESIZE

-- actually supported
G.SHADERS[shader]:send(prefixless_key, args)
G.SHADERS[shader]:send("uibox_size", {self.VT.w, self.VT.h})
G.SHADERS[shader]:send("uibox_pos", {screen_pos.x, screen_pos.y})
G.SHADERS[shader]:send('screen_scale', G.TILESCALE*G.TILESIZE*G.CANV_SCALE)
G.SHADERS[shader]:send("uibox_size", {self.VT.w * tile_scale, self.VT.h * tile_scale})
G.SHADERS[shader]:send("uibox_pos", {self.VT.x * tile_scale, self.VT.y * tile_scale})
-- G.SHADERS[shader]:send("screen_scale", G.TILESCALE*G.TILESIZE*G.CANV_SCALE)

-- placeholder values
G.SHADERS[shader]:send("time",123.33412*(12.5123152)%3000)
-- G.SHADERS[shader]:send("time",123.33412*(12.5123152)%3000) -- if you use this in a shader this is equal to 1543.1953843546
-- G.SHADERS[shader]:send('mouse_screen_pos', {0,0})
-- G.SHADERS[shader]:send('hovering', 0)
-- G.SHADERS[shader]:send("shadow", false)
Expand All @@ -101,13 +88,29 @@ payload = '''
end

if self.config.shader then
_draw_layer(self.config.shader)
elseif self.config.draw_steps then
for _, v in ipairs(self.config.draw_steps) do
if v.shader == "none" or v.shader == "dissolve" then _draw() else
_draw_layer(v.shader, v.send)
-- simple single shader
if type(self.config.shader) == "string" then
_draw_layer(self.config.shader)

-- more complex shader calls
elseif type(self.config.shader) == "table" then
-- one shader pass with a custom send
if self.config.shader.shader then
_draw_layer(self.config.shader.shader, self.config.shader.send)

-- list of shaders
elseif #shader > 0 then
for _, v in ipairs(self.config.shader) do
if type(v) == "string" then
_draw_layer(v.shader)
elseif type(v) == "table" then
_draw_layer(v.shader, v.send)
end
end
end
end

-- no shader
else
_draw()
end
Expand Down