Infravision spell and rant about transparency & particles
Posted: Mon Nov 26, 2012 8:27 am
I was experimenting with transparency for water effects and transparent slimes. It works well, except that my transparent slime is visible through walls.
In short:
After some experimenting with depthBias for monsters, I realised a negative depthBias value has a number of effects. One of them being infinite viewing distance of the object (maybe common knowledge but I had no idea) and it is also needed to make the slime transparent for some reason. So I tried using depthBias on a particleSystem and it works. The asset definition reference doesn't mention it, but it works.
So, I got an idea to use this with my "detect monster" spell to improve it. Have a look:
Clip of Infravision / Detect Monster v2
This goes into spells.lua :
This goes into a script entity named flatlines_script
I am quite satisfied with the effect and I will update my spell library with this version.
Unfortunately, I can't seem to get the transparent slime to NOT be visible through walls.
(please ignore the ugly daytime sky, I am working on a nicer version)
BTW, with a negative depthBias you can make a starry sky 100 steps above the players, that stretches to the horizon, add a moon that acts like a real moon would (so high it seems like a skybox).

In short:
- Asset reference do not mention use of depthDias on particles, but it works
- Negative value makes particles and monsters visible through walls and over longer distances
- Infravision spell is a good example of how it can be used
- "Skyboxes" with particles are also greatly improved
After some experimenting with depthBias for monsters, I realised a negative depthBias value has a number of effects. One of them being infinite viewing distance of the object (maybe common knowledge but I had no idea) and it is also needed to make the slime transparent for some reason. So I tried using depthBias on a particleSystem and it works. The asset definition reference doesn't mention it, but it works.
So, I got an idea to use this with my "detect monster" spell to improve it. Have a look:
Clip of Infravision / Detect Monster v2
This goes into spells.lua :
Code: Select all
---DETECT MONSTER
defineSpell{
name = "DetectMonster",
uiName = "Detect Monster",
skill = "spellcraft",
level = 8,
runes = "BFG",
manaCost = 13,
onCast = function(champ)
return flatlines_script.detectmonster(champ)
end,
}
defineParticleSystem{
name = "DetectMonster",
emitters = {
-- glow
{
emissionRate = 1,
emissionTime = 0,
spawnBurst = true,
maxParticles = 1,
boxMin = {0,0,0},
boxMax = {0,0,0},
sprayAngle = {0,0},
velocity = {0,0},
texture = "assets/textures/particles/glitter_silver.tga",
lifetime = {10, 10},
colorAnimation = false,
color0 = {1, 0.1, 0.1},
-- color1 = {0.1, 1, 0.1},
-- color2 = {0.1, 0.1, 1},
opacity = 1,
fadeIn = 1,
fadeOut = 1,
size = {3, 3},
gravity = {0,0,0},
airResistance = 1,
rotationSpeed = 1,
blendMode = "Additive",
depthBias = -10,
}
}
}Code: Select all
function detectmonster()
local monsters = findAllDetect(party.level, party.x, party.y, {":setAIState"}, "all", false, false, false)
for _, monster in ipairs(monsters) do
spawn("fx", monster.level, monster.x, monster.y, monster.facing)
:setParticleSystem("DetectMonster")
:translate(0, 2, 0)
end
playSound("generic_spell")
end
function findAllDetect(level, x, y, keys, all, surrounding, facing, facingUs)
local answers, r, dx, dy, entity, match, _ = {}, 0
all = all == "all"
local any = not all
if surrounding then r = 1 end
if facing then
dx, dy = getForward(self.facing)
x, y = x + dx, y + dy
end
if keys == nil then keys = {"*"} end
for entity in allEntities(party.level) do
match = true
for _, value in ipairs(keys) do
if value == "*" then pass = true
elseif string.sub(value, 1, 1) == ":" then pass = entity[(string.sub(value, 2))] ~= nil
else pass = string.find(entity.name, value) ~= nil end
if all then match = pass and match
else match = pass end
if (match and any) or ((not match) and all) then break end
end
if match then
dx, dy = getForward(entity.facing)
if (not facingUs) or (facingUs and entity.x + dx == self.x and entity.y + dy == self.y) or (self.x == entity.x and self.y == entity.y) then
answers[# answers + 1] = entity
end
end
end
return answers
end
Unfortunately, I can't seem to get the transparent slime to NOT be visible through walls.
(please ignore the ugly daytime sky, I am working on a nicer version)
BTW, with a negative depthBias you can make a starry sky 100 steps above the players, that stretches to the horizon, add a moon that acts like a real moon would (so high it seems like a skybox).
SpoilerShow
