From 969b1c888733dbae3f9366b51a187383d3cc0cd1 Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Thu, 18 Jul 2013 01:18:42 +0200 Subject: [PATCH] New Flames of Urh'Rok gfx effect --- .../tome/data/birth/classes/corrupted.lua | 4 + .../tome/data/gfx/particles/shadowfire.lua | 41 ++++ .../data/gfx/particles_images/shadowfire.png | Bin 0 -> 2826 bytes .../tome/data/gfx/shaders/shadowfire.frag | 192 ++++++++++++++++++ .../tome/data/gfx/shaders/shadowfire.lua | 39 ++++ 5 files changed, 276 insertions(+) create mode 100644 game/modules/tome/data/gfx/particles_images/shadowfire.png create mode 100644 game/modules/tome/data/gfx/shaders/shadowfire.frag create mode 100644 game/modules/tome/data/gfx/shaders/shadowfire.lua diff --git a/game/modules/tome/data/birth/classes/corrupted.lua b/game/modules/tome/data/birth/classes/corrupted.lua index fb9301dd77..03747069c5 100644 --- a/game/modules/tome/data/birth/classes/corrupted.lua +++ b/game/modules/tome/data/birth/classes/corrupted.lua @@ -16,6 +16,7 @@ -- -- Nicolas Casalini "DarkGod" -- darkgod@te4.org +local Particles = require "engine.Particles" newBirthDescriptor{ type = "class", @@ -103,6 +104,9 @@ newBirthDescriptor{ }, power_source = {arcane=true}, stats = { mag=4, wil=3, con=2, }, + birth_example_particles = { + function(actor) actor:addParticles(Particles.new("shadowfire", 1)) end, + }, talents_types = { ["cunning/survival"]={false, 0}, ["corruption/sanguisuge"]={true, 0.3}, diff --git a/game/modules/tome/data/gfx/particles/shadowfire.lua b/game/modules/tome/data/gfx/particles/shadowfire.lua index 1d705a8776..7a4ef169e7 100644 --- a/game/modules/tome/data/gfx/particles/shadowfire.lua +++ b/game/modules/tome/data/gfx/particles/shadowfire.lua @@ -17,6 +17,45 @@ -- Nicolas Casalini "DarkGod" -- darkgod@te4.org +-------------------------------------------------------------------------------------- +-- Advanced shaders +-------------------------------------------------------------------------------------- +if core.shader.active() then +use_shader = {type="shadowfire"} +base_size = 64 + +local r = 1 +local g = 1 +local b = 1 +local a = 1 + +return { generator = function() + return { + trail = 0, + life = 10, + size = 2*42 * (size_factor or 1), sizev = 0, sizea = 0, + + x = (x or 0) * engine.Map.tile_w, xv = 0, xa = 0, + y = (y or 0) * engine.Map.tile_h, yv = 0, ya = 0, + dir = 0, dirv = dirv, dira = 0, + vel = 0, velv = 0, vela = 0, + + r = r, rv = 0, ra = 0, + g = g, gv = 0, ga = 0, + b = b, bv = 0, ba = 0, + a = a, av = 0, aa = 0, + } +end, }, +function(self) + self.ps:emit(1) +end, +1, +"particles_images/shadowfire" + +-------------------------------------------------------------------------------------- +-- Default +-------------------------------------------------------------------------------------- +else base_size = 32 return { generator = function() @@ -62,3 +101,5 @@ function(self) self.ps:emit(4) end, 80 + +end \ No newline at end of file diff --git a/game/modules/tome/data/gfx/particles_images/shadowfire.png b/game/modules/tome/data/gfx/particles_images/shadowfire.png new file mode 100644 index 0000000000000000000000000000000000000000..c064c0240a8fcd7db2706231f3b01a0988df99fd GIT binary patch literal 2826 zcmb7G`8O2&7yitQF-DAK5@X4}FWEzCijhGWWUJRZnCxY3Y>}~K3zaQ9k&=0vkR?k@ zH6crq5G5i~A<8hq_<FzR`wx82J<om4eeN&!+#jCvq!Db)dAUWo0RX%fc%1z{Q~m`P z=YD^2!lQqmAYu0ACV=)@{M-J(>1kz-1AG5g#nbya`wB7`?-~Zc0rbCsfT9wSeGzfl z!rBZmg%Ci(jy>e;9RYwl-2!*&Y~<v!n{|+Qk3j6Gj;g&JFEV>cPG9gPeu=|S4v(^+ zh=+~x&0uHDppmltrR14RK>mz<!}mu0WMJ!;S-BJ!E;SfR@assv@2y<?%9;6!!)-4A ztQ5Mf*teHN)7|r5Ot5RmAJtMLB0$QE&%p-bsQ-tw6y3dl*)1MP;EPAohr^&Z+ab=t zyj+OxSka}#OsAy2PpKBBb^-T08QfAdVxV9zd(e_t{l}*L`0#3CB!}k$1RO$uRWF%S z!khZ9*jb-#n7e4nI1iThTLdukb39B+IN<T6Soe=u?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ff --git a/game/modules/tome/data/gfx/shaders/shadowfire.frag b/game/modules/tome/data/gfx/shaders/shadowfire.frag new file mode 100644 index 0000000000..ef7a2cc638 --- /dev/null +++ b/game/modules/tome/data/gfx/shaders/shadowfire.frag @@ -0,0 +1,192 @@ +uniform sampler2D tex; +uniform float tick; +uniform float aadjust; +uniform float time_factor = 25000.0; + +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 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 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); + +vec4 permute( vec4 x ) { + + return mod( ( ( x * 34.0 ) + 1.0 ) * x, 289.0 ); + +} + +vec4 taylorInvSqrt( vec4 r ) { + + return 1.79284291400159 - 0.85373472095314 * r; + +} + +float snoise( vec3 v ) { + + const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 ); + const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 ); + + // First corner + + vec3 i = floor( v + dot( v, C.yyy ) ); + vec3 x0 = v - i + dot( i, C.xxx ); + + // Other corners + + vec3 g = step( x0.yzx, x0.xyz ); + vec3 l = 1.0 - g; + vec3 i1 = min( g.xyz, l.zxy ); + vec3 i2 = max( g.xyz, l.zxy ); + + vec3 x1 = x0 - i1 + 1.0 * C.xxx; + vec3 x2 = x0 - i2 + 2.0 * C.xxx; + vec3 x3 = x0 - 1. + 3.0 * C.xxx; + + // Permutations + + i = mod( i, 289.0 ); + vec4 p = permute( permute( permute( + i.z + vec4( 0.0, i1.z, i2.z, 1.0 ) ) + + i.y + vec4( 0.0, i1.y, i2.y, 1.0 ) ) + + i.x + vec4( 0.0, i1.x, i2.x, 1.0 ) ); + + // Gradients + // ( N*N points uniformly over a square, mapped onto an octahedron.) + + float n_ = 1.0 / 7.0; // N=7 + + vec3 ns = n_ * D.wyz - D.xzx; + + vec4 j = p - 49.0 * floor( p * ns.z *ns.z ); // mod(p,N*N) + + vec4 x_ = floor( j * ns.z ); + vec4 y_ = floor( j - 7.0 * x_ ); // mod(j,N) + + vec4 x = x_ *ns.x + ns.yyyy; + vec4 y = y_ *ns.x + ns.yyyy; + vec4 h = 1.0 - abs( x ) - abs( y ); + + vec4 b0 = vec4( x.xy, y.xy ); + vec4 b1 = vec4( x.zw, y.zw ); + + + vec4 s0 = floor( b0 ) * 2.0 + 1.0; + vec4 s1 = floor( b1 ) * 2.0 + 1.0; + vec4 sh = -step( h, vec4( 0.0 ) ); + + vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; + vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; + + vec3 p0 = vec3( a0.xy, h.x ); + vec3 p1 = vec3( a0.zw, h.y ); + vec3 p2 = vec3( a1.xy, h.z ); + vec3 p3 = vec3( a1.zw, h.w ); + + // Normalise gradients + + vec4 norm = taylorInvSqrt( vec4( dot( p0, p0 ), dot( p1, p1 ), dot( p2, p2 ), dot( p3, p3 ) ) ); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + + // Mix final noise value + + vec4 m = max( 0.6 - vec4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 ); + m = m * m; + return 42.0 * dot( m*m, vec4( dot( p0, x0 ), dot( p1, x1 ), + dot( p2, x2 ), dot( p3, x3 ) ) ); + +} + +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) +{ + //firewall + vec2 delta = vec2(0.0, 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 * 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); + return delta; +} + +vec4 GetFireColor(float currTime, vec2 pos, float freqMult, float stretchMult, float ampMult) +{ + 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); +} + +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 + radius.x *= (1.0 + ellipsoidalFactor) * 0.5 + (ellipsoidalFactor - 1.0) * 0.5 * pow(cos(tick / time_factor * oscillationSpeed), 2.0); + + //on-hit wobbling effect + float radiusLen = length(radius); + + float antialiasingCoef = 1.0; + + float sinAlpha = radiusLen * 2.0; + float alpha = 0.0; + if(sinAlpha > 1.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + return; + }else + { + if(sinAlpha > antialiasingRadius) + { + antialiasingCoef = (1.0 - sinAlpha) / (1.0 - antialiasingRadius); + } + alpha = asin(sinAlpha); + } + + 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 c = c1 * c1.a + c2 * (1.0 - c1.a); + + c.a = 1.0 - exp(-c.a * shieldIntensity / cos(alpha)); + + c.a *= aadjust; + c.a *= min(1.0, c.a) * antialiasingCoef; + + gl_FragColor = c; +} diff --git a/game/modules/tome/data/gfx/shaders/shadowfire.lua b/game/modules/tome/data/gfx/shaders/shadowfire.lua new file mode 100644 index 0000000000..842f8ebccd --- /dev/null +++ b/game/modules/tome/data/gfx/shaders/shadowfire.lua @@ -0,0 +1,39 @@ +-- ToME - Tales of Maj'Eyal +-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +return { + frag = "shadowfire", + vert = nil, + args = { + tex = { texture = 0 }, + mainfbo = { texture = 1 }, + color = color or {0.4, 0.7, 1.0}, + time_factor = time_factor or 25000, + aadjust = aadjust or 10, + ellipsoidalFactor = 1.5, + oscillationSpeed = 20.0, + antialiasingRadius = 0.6, + shieldIntensity = 0.15, + leftColor1 = {11.0 / 255.0, 8.0 / 255.0, 10.0 / 255}, + leftColor2 = {171.0 / 255.0, 4.0 / 255.0, 10.0 / 255}, + rightColor1 = {171.0 / 255.0, 4.0 / 255.0, 10.0 / 255}, + rightColor2 = {11.0 / 255.0, 8.0 / 255.0, 10.0 / 255}, + }, + clone = false, +} -- GitLab