diff --git a/assets/shaders/moire.fs b/assets/shaders/moire.fs new file mode 100644 index 0000000..63c61c3 --- /dev/null +++ b/assets/shaders/moire.fs @@ -0,0 +1,151 @@ +#if defined(VERTEX) || __VERSION__ > 100 || defined(GL_FRAGMENT_PRECISION_HIGH) + #define MY_HIGHP_OR_MEDIUMP highp +#else + #define MY_HIGHP_OR_MEDIUMP mediump +#endif + +extern MY_HIGHP_OR_MEDIUMP vec2 moire; +extern MY_HIGHP_OR_MEDIUMP number dissolve; +extern MY_HIGHP_OR_MEDIUMP number time; +extern MY_HIGHP_OR_MEDIUMP vec4 texture_details; +extern MY_HIGHP_OR_MEDIUMP vec2 image_details; +extern bool shadow; +extern MY_HIGHP_OR_MEDIUMP vec4 burn_colour_1; +extern MY_HIGHP_OR_MEDIUMP vec4 burn_colour_2; + +vec4 dissolve_mask(vec4 tex, vec2 texture_coords, vec2 uv) +{ + if (dissolve < 0.001) { + return vec4(shadow ? vec3(0.,0.,0.) : tex.xyz, shadow ? tex.a*0.3: tex.a); + } + + float adjusted_dissolve = (dissolve*dissolve*(3.-2.*dissolve))*1.02 - 0.01; //Adjusting 0.0-1.0 to fall to -0.1 - 1.1 scale so the mask does not pause at extreme values + + float t = time * 10.0 + 2003.; + vec2 floored_uv = (floor((uv*texture_details.ba)))/max(texture_details.b, texture_details.a); + vec2 uv_scaled_centered = (floored_uv - 0.5) * 2.3 * max(texture_details.b, texture_details.a); + + vec2 field_part1 = uv_scaled_centered + 50.*vec2(sin(-t / 143.6340), cos(-t / 99.4324)); + vec2 field_part2 = uv_scaled_centered + 50.*vec2(cos( t / 53.1532), cos( t / 61.4532)); + vec2 field_part3 = uv_scaled_centered + 50.*vec2(sin(-t / 87.53218), sin(-t / 49.0000)); + + float field = (1.+ ( + cos(length(field_part1) / 19.483) + sin(length(field_part2) / 33.155) * cos(field_part2.y / 15.73) + + cos(length(field_part3) / 27.193) * sin(field_part3.x / 21.92) ))/2.; + vec2 borders = vec2(0.2, 0.8); + + float res = (.5 + .5* cos( (adjusted_dissolve) / 82.612 + ( field + -.5 ) *3.14)) + - (floored_uv.x > borders.y ? (floored_uv.x - borders.y)*(5. + 5.*dissolve) : 0.)*(dissolve) + - (floored_uv.y > borders.y ? (floored_uv.y - borders.y)*(5. + 5.*dissolve) : 0.)*(dissolve) + - (floored_uv.x < borders.x ? (borders.x - floored_uv.x)*(5. + 5.*dissolve) : 0.)*(dissolve) + - (floored_uv.y < borders.x ? (borders.x - floored_uv.y)*(5. + 5.*dissolve) : 0.)*(dissolve); + + if (tex.a > 0.01 && burn_colour_1.a > 0.01 && !shadow && res < adjusted_dissolve + 0.8*(0.5-abs(adjusted_dissolve-0.5)) && res > adjusted_dissolve) { + if (!shadow && res < adjusted_dissolve + 0.5*(0.5-abs(adjusted_dissolve-0.5)) && res > adjusted_dissolve) { + tex.rgba = burn_colour_1.rgba; + } else if (burn_colour_2.a > 0.01) { + tex.rgba = burn_colour_2.rgba; + } + } + + return vec4(shadow ? vec3(0.,0.,0.) : tex.xyz, res > adjusted_dissolve ? (shadow ? tex.a*0.3: tex.a) : .0); +} + +number hue(number s, number t, number h) +{ + number hs = mod(h, 1.)*6.; + if (hs < 1.) return (t-s) * hs + s; + if (hs < 3.) return t; + if (hs < 4.) return (t-s) * (4.-hs) + s; + return s; +} + +vec4 RGB(vec4 c) +{ + if (c.y < 0.0001) + return vec4(vec3(c.z), c.a); + + number t = (c.z < .5) ? c.y*c.z + c.z : -c.y*c.z + (c.y+c.z); + number s = 2.0 * c.z - t; + return vec4(hue(s,t,c.x + 1./3.), hue(s,t,c.x), hue(s,t,c.x - 1./3.), c.w); +} + +vec4 HSL(vec4 c) +{ + number low = min(c.r, min(c.g, c.b)); + number high = max(c.r, max(c.g, c.b)); + number delta = high - low; + number sum = high+low; + + vec4 hsl = vec4(.0, .0, .5 * sum, c.a); + if (delta == .0) + return hsl; + + hsl.y = (hsl.z < .5) ? delta / sum : delta / (2.0 - sum); + + if (high == c.r) + hsl.x = (c.g - c.b) / delta; + else if (high == c.g) + hsl.x = (c.b - c.r) / delta + 2.0; + else + hsl.x = (c.r - c.g) / delta + 4.0; + + hsl.x = mod(hsl.x / 6., 1.); + return hsl; +} + +vec4 effect( vec4 colour, Image texture, vec2 texture_coords, vec2 screen_coords ) +{ + vec4 tex = Texel(texture, texture_coords); + vec2 uv = (((texture_coords)*(image_details)) - texture_details.xy*texture_details.ba)/texture_details.ba; + + number low = min(tex.r, min(tex.g, tex.b)); + number high = max(tex.r, max(tex.g, tex.b)); + number delta = high - low; + + number saturation_fac = 1. - max(0., 0.05*(1.1-delta)); + + vec4 hsl = HSL(vec4(tex.r*saturation_fac, tex.g*saturation_fac, tex.b, tex.a)); + + float t = moire.y*2.221 + mod(time,1.); + vec2 floored_uv = (floor((uv*texture_details.ba)))/texture_details.ba; + vec2 uv_scaled_centered = (floored_uv - 0.5) * 50.; + + vec2 field_part1 = uv_scaled_centered + 50.*vec2(sin(-t / 143.6340), cos(-t / 99.4324)); + vec2 field_part2 = uv_scaled_centered + 50.*vec2(cos( t / 53.1532), cos( t / 61.4532)); + vec2 field_part3 = uv_scaled_centered + 50.*vec2(sin(-t / 87.53218), sin(-t / 49.0000)); + + float field = (1.+ ( + cos(length(field_part1) / 19.483) + sin(length(field_part2) / 33.155) * cos(field_part2.y / 15.73) + + cos(length(field_part3) / 27.193) * sin(field_part3.x / 21.92) ))/2.; + + float res = (.5 + .5* cos( (moire.x) * 2.612 + ( field + -.5 ) *3.14)); + hsl.x = length(field_part2); + hsl.z = sin(hsl.z/2.5 - res/4. + sin(moire.y)/8. + 0.5)/1.4; + + + tex.rgb = RGB(hsl).rgb; + + if (tex[3] < 0.7) + tex[3] = tex[3]/3.; + return dissolve_mask(tex*colour, texture_coords, uv); +} + +extern MY_HIGHP_OR_MEDIUMP vec2 mouse_screen_pos; +extern MY_HIGHP_OR_MEDIUMP float hovering; +extern MY_HIGHP_OR_MEDIUMP float screen_scale; + +#ifdef VERTEX +vec4 position( mat4 transform_projection, vec4 vertex_position ) +{ + if (hovering <= 0.){ + return transform_projection * vertex_position; + } + float mid_dist = length(vertex_position.xy - 0.5*love_ScreenSize.xy)/length(love_ScreenSize.xy); + vec2 mouse_offset = (vertex_position.xy - mouse_screen_pos.xy)/screen_scale; + float scale = 0.2*(-0.03 - 0.3*max(0., 0.3-mid_dist)) + *hovering*(length(mouse_offset)*length(mouse_offset))/(2. -mid_dist); + + return transform_projection * vertex_position + vec4(0.,0.,0.,scale); +} +#endif \ No newline at end of file diff --git a/assets/sounds/e_moire.ogg b/assets/sounds/e_moire.ogg new file mode 100644 index 0000000..0ac0737 Binary files /dev/null and b/assets/sounds/e_moire.ogg differ diff --git a/manifest.json b/manifest.json index 302f70c..b0409a7 100644 --- a/manifest.json +++ b/manifest.json @@ -17,5 +17,5 @@ "conflicts": [ "Jen" ], - "version": "1.0.7" + "version": "1.1.0" } \ No newline at end of file diff --git a/src/edition.lua b/src/edition.lua index a1aed17..109f2ba 100644 --- a/src/edition.lua +++ b/src/edition.lua @@ -1,6 +1,26 @@ -SMODS.Sound({key = "e_jumbo", path = "e_jumbo.ogg"}) SMODS.Shader({key = "polygloss", path = "polygloss.fs"}) +SMODS.Shader({key = "moire", path = "moire.fs"}) +SMODS.Sound({key = "e_jumbo", path = "e_jumbo.ogg"}) SMODS.Sound({key = "e_polygloss", path = "e_polygloss.ogg"}) +SMODS.Sound({key = "e_moire", path = "e_moire.ogg"}) + +local function get_weight(self) + return G.GAME.edition_rate * self.weight +end + +local function allow_moire() + if Cryptid then + return true + end + + for _, v in pairs(SMODS.find_card("j_jane_saint")) do + if v.is_attuned then + return true + end + end + + return false +end SMODS.Edition({ key = "polygloss", @@ -26,17 +46,13 @@ SMODS.Edition({ e_chips = Cryptid and 1.01 or nil, e_mult = Cryptid and 1.01 or nil, }, - sound = { - sound = "jane_e_polygloss", - per = 1.2, - vol = 0.4, - }, + sound = {sound = "jane_e_polygloss", per = 1.2, vol = 0.4}, weight = 8, extra_cost = 4, in_shop = true, shader = "polygloss", apply_to_float = false, - loc_vars = function(self) + loc_vars = function(self, _, _) local vars = {self.config.chips, self.config.x_chips} vars[#vars + 1] = self.config.e_chips vars[#vars + 1] = self.config.mult @@ -71,6 +87,7 @@ SMODS.Edition({ } end end, + get_weight = get_weight, }) local jumbo_modifier = Cryptid and 100 or 2 @@ -135,18 +152,66 @@ SMODS.Edition({ card:add_to_deck() end end, - config = {twos_scored = 0}, - sound = { - sound = "jane_e_jumbo", - per = 1, - vol = 0.5, - }, + sound = {sound = "jane_e_jumbo", per = 1, vol = 0.5}, weight = 0.8, in_shop = true, shader = false, extra_cost = 5, apply_to_float = false, + get_weight = get_weight, +}) + +SMODS.Edition({ + key = "moire", + loc_txt = { + name = "Moire", + label = "Moire", + text = Cryptid and {"{C:inactive}#1#{C:jane_RGB}#2#{C:chips}#3#{}#4#{C:mult}#5#"} + or {"{C:inactive}#1#{X:black,C:jane_RGB,s:1.5}#2#{C:chips}#3#{}#4#{C:mult}#5#"}, + }, + config = {mod = Cryptid and 10 or 1.01}, + sound = {sound = "jane_e_moire", per = 1, vol = 0.7}, + weight = 0.8, + extra_cost = 4, + in_shop = true, + shader = "moire", + apply_to_float = false, get_weight = function(self) - return G.GAME.edition_rate * self.weight + return G.GAME.edition_rate * self.weight * (allow_moire() and 1 or 0) + end, + loc_vars = function(self, _, _) + local allow = allow_moire() + + return { + vars = { + allow and "" or "Does nothing", + allow and "^" .. self.config.mod or "?", + allow and " Chips " or "", + allow and "& " or "", + allow and "Mult" or "", + }, + } + end, + calculate = function(self, _, context) + if not allow_moire() or + not (context.post_joker or context.main_scoring and context.cardarea == G.play) then + return + end + + local mod = self.config.mod + + local ret = Cryptid and { + e_chip = mod, + e_mult = mod, + colour = G.C.DARK_EDITION, + } or { + Echip_mod = mod, + Emult_mod = mod, + colour = G.C.jane_RGB, + sound = "talisman_eeechip", + } + + ret.message = "^" .. mod .. " Chips & Mult" + return ret end, }) diff --git a/src/slugcat.lua b/src/slugcat.lua index 9ee63ac..8cebcd8 100644 --- a/src/slugcat.lua +++ b/src/slugcat.lua @@ -517,13 +517,20 @@ SMODS.Joker { e_foil = {chip_mod = 250}, e_polychrome = {xmult_mod = 2.5}, e_jane_polygloss = { + mult = 10, + chips = 10, + x_mult = 2, + x_chips = 2, + p_dollars = 10, + }, + e_jane_moire = { colour = G.C.jane_RGB, sound = "talisman_eeechip", [Cryptid and "EEchip_mod" or "Echip_mod"] = attune, [Cryptid and "EEmult_mod" or "Emult_mod"] = attune, message = (Cryptid and "^^" or "^") .. attune .. " Chips & Mult", }, - })[Cryptid and "e_jane_polygloss" or ((context.other_card or {}).edition or {}).key] + })[Cryptid and "e_jane_moire" or ((context.other_card or {}).edition or {}).key] if trigger then trigger.card = card diff --git a/src/token.lua b/src/token.lua index c317047..831ce03 100644 --- a/src/token.lua +++ b/src/token.lua @@ -79,7 +79,7 @@ for k, v in pairs({ atlas = "janetokens", loc_txt = { name = v[1] .. " Token", - text = {"Creates a" .. vowels[v[1]:sub(1, 1)] and "n" or "" .. " {C:attention}" .. v[1] .. " Tag"}, + text = {"Creates a" .. (vowels[v[1]:sub(1, 1)] and "n" or "") .. " {C:attention}" .. v[1] .. " Tag"}, }, loc_vars = function(_, info_queue, _) info_queue[#info_queue + 1] = G.P_TAGS[k]