Skip to content
Snippets Groups Projects
Commit fd489915 authored by dg's avatar dg
Browse files

When using the Unstoppable talent the screen will turn red

Invisibility got a fullscreen graphical effect
Stealth got a fullscreen graphical effect


git-svn-id: http://svn.net-core.org/repos/t-engine4@1307 51575b47-30f0-44d4-a5cc-537603b46e54
parent 8a8f983d
No related branches found
No related tags found
No related merge requests found
......@@ -241,8 +241,7 @@ function _M:setupDisplayMode()
-- Create the framebuffer
self.fbo = core.display.newFBO(Map.viewport.width, Map.viewport.height)
if self.fbo then self.fbo_shader = Shader.new("main_fbo") end
-- game.fbo_shader:setUniform("blur", 1)
-- game.fbo_shader:setUniform("colorize", {1,0.3,0})
if self.player then self.player:updateMainShader() end
end
function _M:setupMiniMap()
......@@ -435,6 +434,7 @@ function _M:display()
self.level.map:display(0, 0)
self.target:display(0, 0)
self.fbo:use(false)
_3DNoise:bind(1, true)
self.fbo:toScreen(
self.level.map.display_x, self.level.map.display_y,
self.level.map.viewport.width, self.level.map.viewport.height,
......
......@@ -171,11 +171,9 @@ function _M:act()
end
end
-- Set shader HP warning
if game.fbo_shader and self.life ~= self.old_life then
if self.life < self.max_life / 2 then game.fbo_shader:setUniform("hp_warning", 1 - (self.life / self.max_life))
else game.fbo_shader:setUniform("hp_warning", 0) end
end
-- Funky shader things !
self:updateMainShader()
self.old_life = self.life
-- Clean log flasher
......@@ -189,6 +187,29 @@ function _M:act()
end
end
--- Funky shader stuff
function _M:updateMainShader()
if game.fbo_shader then
-- Set shader HP warning
if self.life ~= self.old_life then
if self.life < self.max_life / 2 then game.fbo_shader:setUniform("hp_warning", 1 - (self.life / self.max_life))
else game.fbo_shader:setUniform("hp_warning", 0) end
end
-- Colorize shader
if self:attr("stealth") then game.fbo_shader:setUniform("colorize", {0.7,0.7,0.7})
elseif self:attr("invisible") then game.fbo_shader:setUniform("colorize", {0.4,0.5,0.7})
elseif self:attr("unstoppable") then game.fbo_shader:setUniform("colorize", {1,0.2,0})
else game.fbo_shader:setUniform("colorize", {0,0,0}) -- Disable
end
-- Moving Blur shader
if self:attr("invisible") then game.fbo_shader:setUniform("motionblur", 3)
else game.fbo_shader:setUniform("motionblur", 0) -- Disable
end
end
end
-- Precompute FOV form, for speed
local fovdist = {}
for i = 0, 30 * 30 do
......
uniform float hp_warning;
uniform float motionblur;
uniform float blur;
uniform sampler3D noiseVol;
uniform float tick;
uniform sampler3D noisevol;
uniform vec2 texSize;
uniform sampler2D tex;
uniform vec3 colorize;
......@@ -9,7 +11,68 @@ void main(void)
{
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
if (blur > 0.0)
if (motionblur > 0.0)
{
int blursize = int(motionblur);
vec2 offset = 1.0/texSize;
float fTime0_X = tick / 40000.0;
vec2 coord = gl_TexCoord[0].xy;
float noisy = texture3D(noisevol,vec3(coord,fTime0_X)).r;
float noisy2 = texture3D(noisevol,vec3(coord/5.0,fTime0_X)).r;
float noisy3 = texture3D(noisevol,vec3(coord/7.0,fTime0_X)).r;
float noise = (noisy+noisy2+noisy3)/3.0;
// Center Pixel
vec4 sample = vec4(0.0,0.0,0.0,0.0);
float factor = ((float(blursize)*2.0)+1.0);
factor = factor*factor;
if (noisy < 0.25)
{
for(int i = -blursize; i <= 0; i++)
{
for(int j = -blursize; j <= 0; j++)
{
sample += texture2D(tex, vec2(gl_TexCoord[0].xy+vec2(float(i)*offset.x, float(j)*offset.y)));
}
}
}
else if (noisy < 0.50)
{
for(int i = 0; i <= blursize; i++)
{
for(int j = 0; j <= blursize; j++)
{
sample += texture2D(tex, vec2(gl_TexCoord[0].xy+vec2(float(i)*offset.x, float(j)*offset.y)));
}
}
}
else if (noisy < 0.75)
{
for(int i = 0; i <= blursize; i++)
{
for(int j = -blursize; j <= 0; j++)
{
sample += texture2D(tex, vec2(gl_TexCoord[0].xy+vec2(float(i)*offset.x, float(j)*offset.y)));
}
}
}
else
{
for(int i = -blursize; i <= 0; i++)
{
for(int j = 0; j <= blursize; j++)
{
sample += texture2D(tex, vec2(gl_TexCoord[0].xy+vec2(float(i)*offset.x, float(j)*offset.y)));
}
}
}
sample /= float((blursize*1.5) * (blursize*0.5));
// gl_FragColor = sample * (0.3 + noise * 0.7);
gl_FragColor = sample;
}
else if (blur > 0.0)
{
int blursize = int(blur);
vec2 offset = 1.0/texSize;
......@@ -26,7 +89,7 @@ void main(void)
sample += texture2D(tex, vec2(gl_TexCoord[0].xy+vec2(float(i)*offset.x, float(j)*offset.y)));
}
}
sample /= float((blursize*2.0) * (blursize*2.0));
sample /= float((blur*2.0) * (blur*2.0));
gl_FragColor = sample;
}
......
......@@ -22,7 +22,7 @@ return {
vert = nil,
args = {
tex = { texture = 0 },
noiseVol = { texture = 1 },
noisevol = { texture = 1 },
},
clone = false,
}
......@@ -1571,8 +1571,10 @@ newEffect{
parameters = { hp_per_kill=2 },
activate = function(self, eff)
eff.kills = 0
eff.tmpid = self:addTemporaryValue("unstoppable", 1)
end,
deactivate = function(self, eff)
self:heal(eff.kills * eff.hp_per_kill * self.max_life / 100)
self:removeTemporaryValue("unstoppable", eff.tmpid)
end,
}
......@@ -1106,6 +1106,29 @@ static int sdl_texture_toscreen_full(lua_State *L)
return 0;
}
static int sdl_texture_bind(lua_State *L)
{
GLuint *t = (GLuint*)auxiliar_checkclass(L, "gl{texture}", 1);
int i = luaL_checknumber(L, 2);
bool is3d = lua_toboolean(L, 3);
if (i > 0)
{
if (multitexture_active && shaders_active)
{
glActiveTexture(GL_TEXTURE0+i);
glBindTexture(is3d ? GL_TEXTURE_3D : GL_TEXTURE_2D, *t);
glActiveTexture(GL_TEXTURE0);
}
}
else
{
glBindTexture(is3d ? GL_TEXTURE_3D : GL_TEXTURE_2D, *t);
}
return 0;
}
static bool _CheckGL_Error(const char* GLcall, const char* file, const int line)
{
GLenum errCode;
......@@ -1432,6 +1455,7 @@ static const struct luaL_reg sdl_texture_reg[] =
{"toScreenFull", sdl_texture_toscreen_full},
{"makeOutline", sdl_texture_outline},
{"toSurface", gl_texture_to_sdl},
{"bind", sdl_texture_bind},
{NULL, NULL},
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment