Optimization of a script

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Optimization of a script

Post by Isaac »

I would assume, that one cell equals 3.048 meters, but the game's internal coordinate system could suggest that it's 1.8288 meters per cell.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Optimization of a script

Post by minmay »

One tile is 3x3x[module height] meters.
vieuxchat wrote:In fact I'm not sure I really understand what is the difference between a directionnal light and a point one.
Would a directionnal light always follow the direction of the party ?
There are four types of light, determined by the LightComponent's type field.
"point" - The default. Light is cast in all directions from the LightComponent's position and falls off with distance (the distance depending on the LightComponent's range).
"spot" - Light is cast in a cone from the LightComponent's position. The spotAngle field determines the radius of the cone and the spotSharpness field determines the distance from the axis of the cone at which light falloff starts (0 is immediately, 1 is no falloff at all). The component's rotation determines the direction of the cone, and the range determines the height of the cone. This is used a lot by ceiling shaft lights in the standard assets. Also, they don't render correctly in Wine for some reason.
"ambient" - Light is applied to all triangles on the level. Position and range are not meaningful for ambient lights, and there's no shadow casting. This is what sky objects use for their ambient lights. Note that ambient lighting, while not tremendously demanding, also isn't free, so don't use multiple ambient lights on the same level; combine the colors and intensity into one ambient light instead.
"directional" - You might have heard this kind of light referred to as a "sun" in 3D graphics jargon, and indeed it's what sky objects use for the direct sunlight. Imagine a point or plane which is infinitely distant, and emits uniform light that does not fall off with distance - but does cast shadows. That's the best way I can explain directional lights. (You could also just try one and see.) Position and range are not meaningful for directional lights, but rotation is, since it determines the direction in which the light is cast.
vieuxchat wrote:I thought static shadows = true would be faster than static shadows = false, is it like that or am I wrong ?
Close! You're confusing staticShadow with staticShadowDistance. staticShadow determines whether static shadows are cast by the light at all; staticShadowDistance is the distance in meters from the camera at which point the light will stop casting dynamic shadows. The default static shadow distance is 25m, which happens to exactly match the far clip of the default camera on levels with no SkyComponent.
You can stop a light from casting dynamic shadows at all, but still get static shadows by setting staticShadows = true and staticShadowDistance = 0. This is what the forest_lantern object in the standard assets does.
Also, if the player has shadow quality set to Low in the game options, dynamic shadows aren't cast at all, only static ones, regardless of staticShadowDistance.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
vieuxchat
Posts: 48
Joined: Wed Mar 02, 2016 3:14 pm

Re: Optimization of a script

Post by vieuxchat »

Thanks for the info about light, it's very useful.

Another people has the same slow down but without having its video card doing any noise. So it may be not what I thought it was.
I may have another hint : does a fireball "dies" if it doesn't hit anything ?
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Optimization of a script

Post by kelly1111 »

From what I have read somewhere on these forums, cant remember where...
spells don't "die" when you shoot them into the void... they keep existing
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Optimization of a script

Post by AndakRainor »

You can look here:
viewtopic.php?f=22&t=10014
(or skip to the last posts if you find it too long to read).
vieuxchat
Posts: 48
Joined: Wed Mar 02, 2016 3:14 pm

Re: Optimization of a script

Post by vieuxchat »

Yes ! So, that's it.
Thanks for the thread, it is very useful :)
Post Reply