diff --git a/game/engines/default/engine/Shader.lua b/game/engines/default/engine/Shader.lua index 60d64c6bf5608b9e9f9b8502907ab474b93b7908..f3520d73ed1b0073af4188287cf476b3229255c1 100644 --- a/game/engines/default/engine/Shader.lua +++ b/game/engines/default/engine/Shader.lua @@ -26,6 +26,7 @@ module(..., package.seeall, class.make) _M.verts = {} _M.frags = {} _M.progs = {} +_M.progsreset = {} loadNoDelay = true @@ -153,6 +154,7 @@ function _M:loaded() end _M.progs[self.totalname] = self:createProgram(def) + _M.progsreset[self.totalname] = def.resetargs self.shad = _M.progs[self.totalname] if self.shad then @@ -161,6 +163,12 @@ function _M:loaded() end end end + + if self.shad and _M.progsreset[self.totalname] then + for k, v in pairs(_M.progsreset[self.totalname]) do + self:setUniform(k, v(self)) + end + end end function _M:setUniform(k, v) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 19dc652a3273a7dbfe941bc8e8c97ef78069b2e2..aeb20221d16f2f5e6692b3440225bbaf1c662f57 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -838,10 +838,9 @@ end function _M:makeMapObject(tiles, idx) local mo, z, lastmo = Actor.makeMapObject(self, tiles, idx) + if mo and mo:isValid() then return mo, z, lasmo end if idx == 1 and mo then - if mo and mo:isValid() then return mo, z, lasmo end - local submo = core.map.newObject(self.uid, 1, self:check("display_on_seen"), self:check("display_on_remember"), self:check("display_on_unknown"), self:check("display_x") or 0, self:check("display_y") or 0, self:check("display_w") or 1, self:check("display_h") or 1, self:check("display_scale") or 1) local tex, texx, texy, pos_x, pos_y = tiles:get("", 0, 0, 0, 0, 0, 0, "invis.png", false, false, true) submo:texture(0, tex, false, texx, texy, pos_x, pos_y) diff --git a/game/modules/tome/data/gfx/particles_images/shadowfire.png b/game/modules/tome/data/gfx/particles_images/shadowfire.png index c064c0240a8fcd7db2706231f3b01a0988df99fd..498e5be7e975633390336a9417ec126bc392ef6f 100644 Binary files a/game/modules/tome/data/gfx/particles_images/shadowfire.png and b/game/modules/tome/data/gfx/particles_images/shadowfire.png differ diff --git a/game/modules/tome/data/gfx/shaders/flamewings.frag b/game/modules/tome/data/gfx/shaders/flamewings.frag index f767b0333aaef3430ba3d540ea8eb5ecc83550f7..ab9448c151ea83d168d562df2ddd8e26fb288535 100644 --- a/game/modules/tome/data/gfx/shaders/flamewings.frag +++ b/game/modules/tome/data/gfx/shaders/flamewings.frag @@ -101,41 +101,45 @@ vec2 snoise2(vec3 pos) return vec2(snoise(pos), snoise(pos + vec3(0.0, 0.0, 1.0))); } -vec2 GetFireDelta(float currTime, vec2 pos, float freqMult, float stretchMult) +float GetFireDelta(float currTime, vec2 pos, float freqMult, float stretchMult, float scrollSpeed, float evolutionSpeed) { //firewall - vec2 delta = vec2(0.0, 0.0); + float delta = 0.0; // pos.y += (1.0 - pos.y) * 0.5; //pos.y += 0.5; pos.y /= stretchMult; pos *= freqMult; - pos.y += currTime * 3.0; + pos.y += currTime * scrollSpeed; + // pos.y -= currTime * 3.0; - delta += vec2(0.0, snoise(vec3(pos * 1.0, currTime * 0.5)) * 1.5); - delta += vec2(0.0, snoise(vec3(pos * 2.0, currTime * 1.0)) * 1.5); - delta += vec2(0.0, snoise(vec3(pos * 4.0, currTime * 2.0)) * 1.5); - delta += vec2(0.0, snoise(vec3(pos * 8.0, currTime * 4.0)) * 1.5); - delta += vec2(0.0, snoise(vec3(pos * 16.0, currTime * 8.0)) * 0.5); - /*delta += vec2(0.0, snoise(vec3(pos * 2.0, 1*currTime * 4.0)) * 0.4); - delta += vec2(0.0, snoise(vec3(pos * 8.0, 1*currTime * 16.0)) * 0.8); - delta += vec2(0.0, snoise(vec3(pos * 16.0, 1*currTime * 32.0)) * 0.4);*/ + delta += snoise(vec3(pos * 1.0, currTime * 1.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 2.0, currTime * 2.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 4.0, currTime * 4.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 8.0, currTime * 8.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 16.0, currTime * 16.0 * evolutionSpeed)) * 0.5; + return delta; } vec4 GetFireColor(float currTime, vec2 pos, float freqMult, float stretchMult, float ampMult) { - if(pos.x < 0.0 || pos.x > 1.0 || pos.y < 0.0 || pos.y > 1.0) return vec4(0.0, 0.0, 0.0, 0.0); - /*if(mod(pos.x, 0.1) < 0.05 ^ mod(pos.y, 0.1) < 0.05) - return vec4(pos.x, pos.y, 0, 1); - else - return vec4(0, 0, 0, 1);*/ - vec2 delta = GetFireDelta(currTime, pos, freqMult, stretchMult); - delta *= min(1.0, max(0.0, 1.0 * (1.0 - pos.y))); - delta *= min(1.0, max(0.0, 1.0 * (0.0 + pos.y))); - vec2 displacedPoint = pos + delta * ampMult; - displacedPoint.y = min(0.99, displacedPoint.y); - displacedPoint.y = max(0.01, displacedPoint.y); - return texture2D(tex, displacedPoint); + vec4 fireColor = vec4(0.0, 0.0, 0.0, 0.0); + if(pos.x > 0.0 && pos.x < 1.0 && pos.y > 0.0 && pos.y < 1.0) + { + /*if(mod(pos.x, 0.1) < 0.05 ^ mod(pos.y, 0.1) < 0.05) + return vec4(pos.x, pos.y, 0, 1); + else + return vec4(0, 0, 0, 1);*/ + float delta = GetFireDelta(currTime, pos, freqMult, stretchMult, 3.0, 0.1); + delta *= min(1.0, max(0.0, 1.0 * (1.0 - pos.y))); + delta *= min(1.0, max(0.0, 1.0 * (0.0 + pos.y))); + vec2 displacedPoint = pos + vec2(0, delta * ampMult); + displacedPoint.y = min(0.99, displacedPoint.y); + displacedPoint.y = max(0.01, displacedPoint.y); + + fireColor = texture2D(tex, displacedPoint); + } + return fireColor; } void main(void) @@ -144,16 +148,15 @@ void main(void) pos.x = 0.5 + (pos.x - 0.5) * ellipsoidalFactor; pos = vec2(0.5, 0.5) + (pos - vec2(0.5, 0.5)) * 1.1; - float foldRatio = 1.0; -// float foldRatio = max(0.0, min(1.0, (tick - tick_start) / time_factor * 0.5)); -// foldRatio = (1.0 + sin(tick / time_factor * 20.0)) * 0.5; + float foldRatio = max(0.0, min(1.0, (tick - tick_start) / time_factor * 5.0)); + //foldRatio = (1.0 + sin(tick / time_factor * 20.0)) * 0.5; foldRatio *= 0.95 + 0.05 * sin(tick / time_factor * 15.0); float radius = 0.25 * (foldRatio * 0.5 + 0.5); vec2 center = vec2(0.5, 0.85 - radius); float timeShift = 0.0; if(pos.x > 0.5) - timeShift = 100; + timeShift = 100.0; if(length(pos - center) < radius) diff --git a/game/modules/tome/data/gfx/shaders/flamewings.lua b/game/modules/tome/data/gfx/shaders/flamewings.lua index 5114faecfe82af0ec60bc4f10491fabbc9e67c21..377de4ebdfdae3ab745236dfd52a76d9f251954d 100644 --- a/game/modules/tome/data/gfx/shaders/flamewings.lua +++ b/game/modules/tome/data/gfx/shaders/flamewings.lua @@ -22,11 +22,13 @@ return { vert = nil, args = { tex = { texture = 0 }, - tick_start = core.game.getTime(), time_factor = 6000, ellipsoidalFactor = 1.7, --1 is perfect circle, >1 is ellipsoidal oscillationSpeed = 0.0, --oscillation between ellipsoidal and spherical form growRatio = 1.0, }, + resetargs = { + tick_start = function() return core.game.getTime() end, + }, clone = false, } diff --git a/game/modules/tome/data/gfx/shaders/shadowfire.frag b/game/modules/tome/data/gfx/shaders/shadowfire.frag index ef7a2cc6385019b2bbb7d7ca3cd902bc042fc024..335e33cd77f44177ff8e9ae693cb205a6036a5e3 100644 --- a/game/modules/tome/data/gfx/shaders/shadowfire.frag +++ b/game/modules/tome/data/gfx/shaders/shadowfire.frag @@ -1,19 +1,17 @@ uniform sampler2D tex; uniform float tick; uniform float aadjust; -uniform float time_factor = 25000.0; +uniform vec3 color; +uniform float time_factor; -uniform float ellipsoidalFactor = 1.5; //1 is perfect circle, >1 is ellipsoidal -uniform float oscillationSpeed = 20.0; //oscillation between ellipsoidal and spherical form +uniform float ellipsoidalFactor = 1.4; //1 is perfect circle, >1 is ellipsoidal +uniform float oscillationSpeed = 10.0; //oscillation between ellipsoidal and spherical form uniform float antialiasingRadius = 0.6; //1.0 is no antialiasing, 0.0 - fully smoothed(looks worse) -uniform float shieldIntensity = 0.15; //physically affects shield layer thickness +uniform float shieldIntensity = 0.2; //physically affects shield layer thickness -uniform vec4 leftColor1 = vec4(11.0 / 255.0, 8.0 / 255.0, 10.0 / 255.0, 1.0); -uniform vec4 leftColor2 = vec4(171.0 / 255.0, 4.0 / 255.0, 10.0 / 255.0, 1.0); - -uniform vec4 rightColor1 = vec4(171.0 / 255.0, 4.0 / 255.0, 10.0 / 255.0, 1.0); -uniform vec4 rightColor2 = vec4(11.0 / 255.0, 8.0 / 255.0, 10.0 / 255.0, 1.0); +uniform vec4 color1 = vec4(11.0 / 255.0, 8.0 / 255.0, 10.0 / 255.0, 1.0); +uniform vec4 color2 = vec4(171.0 / 255.0, 4.0 / 255.0, 10.0 / 255.0, 1.0); vec4 permute( vec4 x ) { @@ -112,37 +110,40 @@ vec2 snoise2(vec3 pos) -vec2 GetFireDelta(float currTime, vec2 pos, float freqMult, float stretchMult) +float GetFireDelta(float currTime, vec2 pos, float freqMult, float stretchMult, float scrollSpeed, float evolutionSpeed) { //firewall - vec2 delta = vec2(0.0, 0.0); + float delta = 0; // pos.y += (1.0 - pos.y) * 0.5; //pos.y += 0.5; pos.y /= stretchMult; pos *= freqMult; - pos.y -= currTime * 3.0; -// pos.y -= currTime * 3.0; - delta += vec2(0.0, snoise(vec3(pos * 1.0, currTime * 2.0)) * 0.8); - delta += vec2(0.0, snoise(vec3(pos * 2.0, currTime * 4.0)) * 0.4); - delta += vec2(0.0, snoise(vec3(pos * 8.0, currTime * 16.0)) * 0.8); - delta += vec2(0.0, snoise(vec3(pos * 16.0, currTime * 32.0)) * 0.4); + pos.y += currTime * scrollSpeed; + + delta += snoise(vec3(pos * 1.0, currTime * 1.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 2.0, currTime * 2.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 4.0, currTime * 4.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 8.0, currTime * 8.0 * evolutionSpeed)) * 1.5; + delta += snoise(vec3(pos * 16.0, currTime * 16.0 * evolutionSpeed)) * 0.5; + return delta; } -vec4 GetFireColor(float currTime, vec2 pos, float freqMult, float stretchMult, float ampMult) +vec4 GetFireColor(float currTime, vec2 pos, float freqMult, float stretchMult, float ampMult, float textureCoord) { - vec2 delta = GetFireDelta(currTime, pos, freqMult, stretchMult); + float delta = GetFireDelta(currTime, pos, freqMult, stretchMult, 3.0, 0.5); delta *= min(1.0, max(0.0, 1.0 * (1.0 - pos.y))); delta *= min(1.0, max(0.0, 1.0 * (0.0 + pos.y))); - vec2 displacedPoint = pos + delta * ampMult; + vec2 displacedPoint = pos + vec2(0, delta * ampMult); displacedPoint.y = min(0.99, displacedPoint.y); displacedPoint.y = max(0.01, displacedPoint.y); + displacedPoint.x = textureCoord; + return texture2D(tex, displacedPoint); } void main(void) { - shieldIntensity = 0.2; vec2 radius = vec2(0.5, 0.5) - gl_TexCoord[0].xy; //radius.x *= ellispoidalFactor; //for simple ellipsoid //comment next line for regular spherical shield @@ -169,18 +170,9 @@ void main(void) } vec2 sphericalProjectedCoord = vec2(0.5, 0.5) + radius * (alpha / (3.141592 / 2.0)) / radiusLen; - - float verticalRatio = gl_TexCoord[0].y; - if(verticalRatio < 0.5) - verticalRatio = pow(verticalRatio * 2.0, 1.0) / 2.0; - else - verticalRatio = 1.0 - pow((1.0 - verticalRatio) * 2.0, 1.0) / 2.0; - - vec4 leftColor = leftColor1 * verticalRatio + leftColor2 * (1.0 - verticalRatio); - vec4 rightColor = rightColor1 * verticalRatio + rightColor2 * (1.0 - verticalRatio); - vec4 c1 = GetFireColor(tick / time_factor + 0.0 , vec2(sphericalProjectedCoord.y, (-0.3 + 0.0 + sphericalProjectedCoord.x) * 0.7), 1.0, 2.0, 1.0) * leftColor; - vec4 c2 = GetFireColor(tick / time_factor + 10.0, vec2(sphericalProjectedCoord.y, (-0.3 + 1.0 - sphericalProjectedCoord.x) * 0.7), 1.0, 2.0, 1.0) * rightColor; + vec4 c1 = GetFireColor(tick / time_factor + 0.0 , vec2(sphericalProjectedCoord.y, (-0.2 + 0.0 + sphericalProjectedCoord.x) * 0.8), 1.0, 2.0, 1.0, 0.25); + vec4 c2 = GetFireColor(tick / time_factor + 10.0, vec2(sphericalProjectedCoord.y, (-0.2 + 1.0 - sphericalProjectedCoord.x) * 0.8), 1.0, 2.0, 1.0, 0.75); vec4 c = c1 * c1.a + c2 * (1.0 - c1.a); c.a = 1.0 - exp(-c.a * shieldIntensity / cos(alpha));