about optimization

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
undeaddemon
Posts: 157
Joined: Fri Mar 02, 2012 3:38 pm

Re: about optimization

Post by undeaddemon »

OK... cool - building some context here.

I can't really tell / haven't run any test builds showing framerates.

I do have a 12x13 room that does have - about 14 lamps (ceiling mid and floor) towards the center, and various other along the perimeter. however, it is, from a polygon perspective, low detail (only daemon faces on perimeter)

Is there something in the editor I can use to show frame rates?
User avatar
Pandafox
Posts: 268
Joined: Wed Apr 11, 2012 11:25 pm
Location: France
Contact:

Re: about optimization

Post by Pandafox »

I have a strange problem with one of my "puzzle room"
There are some FX which appears at the same time (7 or 8 at the same time).

In the editor I don't have any problem, but when I try it in game, the framerate is horrible ! I think I am under 15 FPS!
When the puzzle is finished to resolve, I destroy the particles and it come back normal framerate...
I think I have to change my FX or maybe change my puzzle...

I am not professional as coding then maybe I made a big mistake, here you can see the code :
If someone can help me it should be very nice :)

defineObject{
name = "chemin_lum",
class = "LightSource",
lightPosition = vec(0, 0, 0),
lightRange = 0,
lightColor = vec(0.4, 0.3, 2.2),
brightness = 4,
castShadow = false,
particleSystem = "lightway",
placement = "floor",
editorIcon = 88,
}


defineParticleSystem{
name = "lightway",
emitters = {
{
emissionRate = 20,
emissionTime = 1,
maxParticles = 100,
boxMin = {-1, 0.2, -1},
boxMax = { 1, 0.2, 1},
sprayAngle = {0,90},
velocity = {0.1, 0.4},
texture = "assets/textures/particles/torch_flame.tga",
frameRate = 20,
frameSize = 64,
frameCount = 16,
lifetime = {0.5, 1},
colorAnimation = true,
color0 = {0.1, 0, 2},
color1 = {0.1, 0, 1.2},
color2 = {0.1, 0, 8},
color3 = {0.1, 0, 0.2},
opacity = 2,
fadeIn = 0.5,
fadeOut = 1,
size = {0.15, 0.005},
gravity = {0,0,0},
airResistance = 0.2,
rotationSpeed = 0.3,
blendMode = "Additive",
}
}
}
User avatar
Phitt
Posts: 442
Joined: Tue Aug 14, 2012 9:43 am

Re: about optimization

Post by Phitt »

undeaddemon wrote:OK... cool - building some context here.

I can't really tell / haven't run any test builds showing framerates.

I do have a 12x13 room that does have - about 14 lamps (ceiling mid and floor) towards the center, and various other along the perimeter. however, it is, from a polygon perspective, low detail (only daemon faces on perimeter)

Is there something in the editor I can use to show frame rates?
14 lamps plus X in this relatively small space will certainly turn the game into a slide show on low end systems and will cause a low framerate on an average machine like mine, low enough to make the game less fun to play (below 30). Unless you add tons of high poly stuff like monsters, statues etc detail doesn't matter that much. Do you really need all those lights? Often a few well placed lights add more to the atmosphere than just filling up everything with lights. Of course people with high end systems can still enjoy your mod, but if I had to play it I certainly would be annoyed by the low framerate. Light overkill is actually one of the biggest problems in Grimrock mods in my opinion, I've seen a lot of mods with 10+ lights in a small area - and in most cases it didn't even look very good.

I don't think the editor has a frame counter, but you can use FRAPS (basic version is free, also useful for taking screenshots or recording videos) or ATI/nVidia tray tools to show the framerate. Note that the framerate in the editor is different from the one you see in game, usually it is lower than in the game.

@Pandafox: How do you enable the particles? Emission time is set to 1, so normally the emitter should only emit particles for 1 second. Could it be that you keep creating light objects by script and that's why the framerate is so low? Other than that I don't see how the particles could cause such a low framerate since there aren't many particles and the lights are ok as well.
User avatar
Pandafox
Posts: 268
Joined: Wed Apr 11, 2012 11:25 pm
Location: France
Contact:

Re: about optimization

Post by Pandafox »

Thanks Phitt to try to help me ;)
I put a video online to show what it is about...
https://vimeo.com/57077734

Sorry for the bad quality video, it was quickly done and encoded...

In this room, there is a "light way" to follow.
it works with timers. Each FX have a timer which stats the next timer......
Every 7 timers, I destroy the 7th before FX. at timer 7, I destroy the FX1, at timer 8 I destroy the FX2, ... ... ...
Then I always have only 7 FX at the same time.

The video was taken in the editor. There is no framerate problem at all.
But as I said before, when I try it in game, it make my framerate horrible... I can't understand why.... :?
User avatar
Phitt
Posts: 442
Joined: Tue Aug 14, 2012 9:43 am

Re: about optimization

Post by Phitt »

Pandafox wrote:Thanks Phitt to try to help me ;)
I put a video online to show what it is about...
[...]
Can you post the script and the exact specifications of the your timer setup? I could imagine you didn't stop the timers and the fx get created indefinitely, which would cause lag after a very short time. But it's hard to say without knowing exactly what you do.
User avatar
Pandafox
Posts: 268
Joined: Wed Apr 11, 2012 11:25 pm
Location: France
Contact:

Re: about optimization

Post by Pandafox »

it's a shame.... :oops: because I know my code is very not perfect, I could make cleaner one by creating all dynamicly...
but I used a "dirty" method...

There are a way of 24 steps to "illuminate"
I created 24 timers :oops:
I created one srcipt which contains :
SpoilerShow
function way01()
spawn("chemin_lum", party.level, 18, 1, 0, "lw1")
end

function way02()
spawn("chemin_lum", party.level, 19, 1, 0, "lw2")
end

function way03()
spawn("chemin_lum", party.level, 19, 0, 0, "lw3")
end

function way04()
spawn("chemin_lum", party.level, 20, 0, 0, "lw4")
end

function way05()
spawn("chemin_lum", party.level, 21, 0, 0, "lw5")
end

function way06()
spawn("chemin_lum", party.level, 21, 1, 0, "lw6")
end

function way07()
spawn("chemin_lum", party.level, 21, 2, 0, "lw7")
if findEntity ("lw1") then lw1:destroy() end
end

function way08()
spawn("chemin_lum", party.level, 22, 2, 0, "lw8")
if findEntity ("lw2") then lw2:destroy() end
end

function way09()
spawn("chemin_lum", party.level, 23, 2, 0, "lw9")
if findEntity ("lw3") then lw3:destroy() end
end

function way10()
spawn("chemin_lum", party.level, 24, 2, 0, "lw10")
if findEntity ("lw4") then lw4:destroy() end
end

function way11()
spawn("chemin_lum", party.level, 24, 1, 0, "lw11")
if findEntity ("lw5") then lw5:destroy() end
end

function way12()
spawn("chemin_lum", party.level, 24, 0, 0, "lw12")
if findEntity ("lw6") then lw6:destroy() end
end

function way13()
spawn("chemin_lum", party.level, 25, 0, 0, "lw13")
if findEntity ("lw7") then lw7:destroy() end
end

function way14()
spawn("chemin_lum", party.level, 26, 0, 0, "lw14")
if findEntity ("lw8") then lw8:destroy() end
end

function way15()
spawn("chemin_lum", party.level, 27, 0, 0, "lw15")
if findEntity ("lw9") then lw9:destroy() end
end

function way16()
spawn("chemin_lum", party.level, 28, 0, 0, "lw16")
if findEntity ("lw10") then lw10:destroy() end
end

function way17()
spawn("chemin_lum", party.level, 28, 1, 0, "lw17")
if findEntity ("lw11") then lw11:destroy() end
end

function way18()
spawn("chemin_lum", party.level, 28, 2, 0, "lw18")
if findEntity ("lw12") then lw12:destroy() end
end

function way19()
spawn("chemin_lum", party.level, 29, 2, 0, "lw19")
if findEntity ("lw13") then lw13:destroy() end
end

function way20()
spawn("chemin_lum", party.level, 30, 2, 0, "lw20")
if findEntity ("lw14") then lw14:destroy() end
end

function way21()
spawn("chemin_lum", party.level, 31, 2, 0, "lw21")
if findEntity ("lw15") then lw15:destroy() end
end

function way22()
spawn("chemin_lum", party.level, 31, 3, 0, "lw22")
if findEntity ("lw16") then lw16:destroy() end
end

function way23()
spawn("chemin_lum", party.level, 31, 4, 0, "lw23")
if findEntity ("lw17") then lw17:destroy() end
end

function way24()
spawn("chemin_lum", party.level, 30, 4, 0, "lw24")
if findEntity ("lw18") then lw18:destroy() end
end
The first timer starts the first function, activates the second timer and desactivate itself,
the second timer starts the second function, activates the 3th timer and desactivates itself...
...
...
...

Also, at the timer7, I start to destroy the previous FX :
the timer7 destroy the FX1,
the timer8 destroy the FX2,
...
...
...

the last timer start the script to be sure to destroy all
SpoilerShow
function destway()
if findEntity ("lw1") then lw1:destroy() end
if findEntity ("lw2") then lw2:destroy() end
if findEntity ("lw3") then lw3:destroy() end
if findEntity ("lw4") then lw4:destroy() end
if findEntity ("lw5") then lw5:destroy() end
if findEntity ("lw6") then lw6:destroy() end
if findEntity ("lw7") then lw7:destroy() end
if findEntity ("lw8") then lw8:destroy() end
if findEntity ("lw9") then lw9:destroy() end
if findEntity ("lw10") then lw10:destroy() end
if findEntity ("lw11") then lw11:destroy() end
if findEntity ("lw12") then lw12:destroy() end
if findEntity ("lw13") then lw13:destroy() end
if findEntity ("lw14") then lw14:destroy() end
if findEntity ("lw15") then lw15:destroy() end
if findEntity ("lw16") then lw16:destroy() end
if findEntity ("lw17") then lw17:destroy() end
if findEntity ("lw18") then lw18:destroy() end
if findEntity ("lw19") then lw19:destroy() end
if findEntity ("lw20") then lw20:destroy() end
if findEntity ("lw21") then lw21:destroy() end
if findEntity ("lw22") then lw22:destroy() end
if findEntity ("lw23") then lw23:destroy() end
if findEntity ("lw24") then lw24:destroy() end
end
And restarts the first timer...
Again and again until the party go out the room.
User avatar
Phitt
Posts: 442
Joined: Tue Aug 14, 2012 9:43 am

Re: about optimization

Post by Phitt »

Pandafox wrote:it's a shame.... :oops: because I know my code is very not perfect, I could make cleaner one by creating all dynamicly...
but I used a "dirty" method...
[...]
Maybe the lights and the thousands of timers are a problem? No idea. Try this:

Code: Select all

counter = 0

function lwpath()

if counter == 0 then
	if findEntity("lw01") == nil then
		local lw = spawn("fx", party.level, 18, 1, 0, "lw01")
		lw01:setParticleSystem("lightway")
	end
elseif counter == 1 then
	if findEntity("lw02") == nil then
		local lw = spawn("fx", party.level, 19, 1, 0, "lw02")
		lw02:setParticleSystem("lightway")
	end
elseif counter == 2 then
	if findEntity("lw03") == nil then
		local lw = spawn("fx", party.level, 19, 0, 0, "lw03")
		lw03:setParticleSystem("lightway")
	end
elseif counter == 3 then
	if findEntity("lw04") == nil then
		local lw = spawn("fx", party.level, 20, 0, 0, "lw04")
		lw04:setParticleSystem("lightway")
	end
elseif counter == 4 then
	if findEntity("lw05") == nil then
		local lw = spawn("fx", party.level, 21, 0, 0, "lw05")
		lw05:setParticleSystem("lightway")
	end
elseif counter == 5 then
	if findEntity("lw06") == nil then
		local lw = spawn("fx", party.level, 21, 1, 0, "lw06")
		lw06:setParticleSystem("lightway")
	end
elseif counter == 6 then
	if findEntity("lw07") == nil then
		local lw = spawn("fx", party.level, 21, 2, 0, "lw07")
		lw07:setParticleSystem("lightway")
	end
elseif counter == 7 then
	if findEntity("lw08") == nil then
		local lw = spawn("fx", party.level, 22, 2, 0, "lw08")
		lw08:setParticleSystem("lightway")
	end
elseif counter == 8 then
	if findEntity("lw09") == nil then
		local lw = spawn("fx", party.level, 23, 2, 0, "lw09")
		lw09:setParticleSystem("lightway")
	end
elseif counter == 9 then
	if findEntity("lw10") == nil then
		local lw = spawn("fx", party.level, 24, 2, 0, "lw10")
		lw10:setParticleSystem("lightway")
	end
elseif counter == 10 then
	if findEntity("lw11") == nil then
		local lw = spawn("fx", party.level, 24, 1, 0, "lw11")
		lw11:setParticleSystem("lightway")
	end
elseif counter == 11 then
	if findEntity("lw12") == nil then
		local lw = spawn("fx", party.level, 24, 0, 0, "lw12")
		lw12:setParticleSystem("lightway")
	end
elseif counter == 12 then
	if findEntity("lw13") == nil then
		local lw = spawn("fx", party.level, 25, 0, 0, "lw13")
		lw13:setParticleSystem("lightway")
	end
elseif counter == 13 then
	if findEntity("lw14") == nil then
		local lw = spawn("fx", party.level, 26, 0, 0, "lw14")
		lw14:setParticleSystem("lightway")
	end
elseif counter == 14 then
	if findEntity("lw15") == nil then
		local lw = spawn("fx", party.level, 27, 0, 0, "lw15")
		lw15:setParticleSystem("lightway")
	end
elseif counter == 15 then
	if findEntity("lw16") == nil then
		local lw = spawn("fx", party.level, 28, 0, 0, "lw16")
		lw16:setParticleSystem("lightway")
	end
elseif counter == 16 then
	if findEntity("lw17") == nil then
		local lw = spawn("fx", party.level, 28, 1, 0, "lw17")
		lw17:setParticleSystem("lightway")
	end
elseif counter == 17 then
	if findEntity("lw18") == nil then
		local lw = spawn("fx", party.level, 28, 2, 0, "lw18")
		lw18:setParticleSystem("lightway")
	end
elseif counter == 18 then
	if findEntity("lw19") == nil then
		local lw = spawn("fx", party.level, 29, 2, 0, "lw19")
		lw19:setParticleSystem("lightway")
	end
elseif counter == 19 then
	if findEntity("lw20") == nil then
		local lw = spawn("fx", party.level, 30, 2, 0, "lw20")
		lw20:setParticleSystem("lightway")
	end
elseif counter == 20 then
	if findEntity("lw21") == nil then
		local lw = spawn("fx", party.level, 31, 2, 0, "lw21")
		lw21:setParticleSystem("lightway")
	end
elseif counter == 21 then
	if findEntity("lw22") == nil then
		local lw = spawn("fx", party.level, 31, 3, 0, "lw22")
		lw22:setParticleSystem("lightway")
	end
elseif counter == 22 then
	if findEntity("lw23") == nil then
		local lw = spawn("fx", party.level, 31, 4, 0, "lw23")
		lw23:setParticleSystem("lightway")
	end
elseif counter == 23 then
	if findEntity("lw24") == nil then
		local lw = spawn("fx", party.level, 30, 4, 0, "lw24")
		lw24:setParticleSystem("lightway")
	end
end

if counter ~= 23 then
counter = counter + 1
else
counter = 0
end

end
Copy/paste it (click select all) into a lua script and create a single timer and connect the timer with the function. It should work just like your script, but hopefully it will solve the performance problems.

EDIT: If that doesn't help then maybe it would be a good idea to use a particle that is not animated. You can hardly see the flame flickering at that speed and a regular particle will certainly be much better for performance.
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: about optimization

Post by Neikun »

One way to fill a room with light is to make a single light with increased brightness/range
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
odinsballs
Posts: 288
Joined: Thu Dec 20, 2012 4:25 pm
Location: south of heaven

Re: about optimization

Post by odinsballs »

what neikun said, i took the "ceiling light outside" from yuleland sourcefile and crossbred it with "sunlight mine entrance light" settings (color), and made a stable lightsource ( daylight effect) for 5x5 or 7x7 rooms, i gues best approach would be to create 1 a 2 lightsources with sufficient range and fitting color atmosphere per larger rooms ( do believe me, the torches cause a graphic lagg stink too) . :shock: :shock:
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: about optimization

Post by Neikun »

One thing to watch out for: Increased brightness/range = decreased shadow quality of things like monsters.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
Post Reply