don't feel sorry chances are i wouldn't comprehend half of it anyhoo, (i'm not realy handy scriptwise) but its good to know that its coming along ( i have released an exterior deco pack myself but i think that might be a bit too heavy), next question: i'm working on some outdoor spaces too and i am wondering.... once the lotnr is ready and sources are available do i have to recreate my whole world segments or can i just ditch the (modified yuleland ) skyboxes (since the lotnr skybox seems to be modified version of hardcoded b(l)ackground) thusly being rendered correctly in background.Neikun wrote:It's a spawned particle I think.
I want to go into more detail, but I feel like my head just emptied out as soon as I tried to answer.
Sorry!
LotNR Project Official Thread [Open]
- odinsballs
- Posts: 288
- Joined: Thu Dec 20, 2012 4:25 pm
- Location: south of heaven
Re: LotNR Project Official Thread [Open]
Re: LotNR Project Official Thread [Open]
Short how-to on making a "sky box"(it isn't really a sky box, but the effect is similar):
Create a sky texture, use it as a particle spread out to very large x & z values. Place it at some height above the party. A single particle can cover the entire sky. The only issues are clipping at the horizon (dark areas that the engine usually covers with walls, covered by the buildings in the videos) and the fact that particles such as the sun can clip a lot when using free view. Another issue is that the sun and the moon are too close to the viewer, this is noticeable when moving. You can counter it by placing them higher up in the sky (increase the Y-value), but then you have to set the depthbias of the texture used on particles to negative to make them always visible no matter how far away they are, which means the particle will be visible even through roofs/houses/whatever. At least, that is my experience of creating an open sky.
Create a sky texture, use it as a particle spread out to very large x & z values. Place it at some height above the party. A single particle can cover the entire sky. The only issues are clipping at the horizon (dark areas that the engine usually covers with walls, covered by the buildings in the videos) and the fact that particles such as the sun can clip a lot when using free view. Another issue is that the sun and the moon are too close to the viewer, this is noticeable when moving. You can counter it by placing them higher up in the sky (increase the Y-value), but then you have to set the depthbias of the texture used on particles to negative to make them always visible no matter how far away they are, which means the particle will be visible even through roofs/houses/whatever. At least, that is my experience of creating an open sky.
Re: LotNR Project Official Thread [Open]
I can answer this as I made it! But just a little bit later, right now I don't have time for a lenghty explanation. But I will, promised .odinsballs wrote:thats a good thing then, please do enlighten me how did you guys do it ?, if i might ask. (it is impressive)Neikun wrote:I didn't notice any change.
The only time I ever experienced bogging down was when too many wip weather pieces were visible at the same time.
While you wait, here's another video of the current version in action: http://youtu.be/RyX7iUs9eFA.
It features the new fully working Ambiance sytem. There's still tweaks to be made to the ambiances, but it gives you a good idea. Ambiances are defined like this, quite flexible, and switchable at will:
Code: Select all
defineAmbiance{
name = "day",
skySphere = "dx_skysphere_blue",
skyLightColor = {1.0, 0.9, 0.7},
skyLightBrightness = 12,
skyLightParticleSystem = "dx_sun",
clouds = "dx_clouds_01",
cloudsFrequence = 5,
}
defineAmbiance{
name = "night",
stars = "dx_stars",
skyLightColor = {0.6, 0.7, 1.1},
skyLightBrightness = 1.5,
clouds = "dx_clouds_dark",
cloudsFrequence = 3,
}
defineAmbiance{
name = "dark_night",
stars = "dx_dark_stars",
skyLightColor = {0.6, 0.7, 1.0},
skyLightBrightness = 0.3,
clouds = "dx_clouds_dark",
cloudsFrequence = 5,
}
defineAmbiance{
name = "rainy_day",
skySphere = "dx_skysphere_grey",
skyLightColor = {0.9, 0.9, 0.9},
skyLightBrightness = 8,
skyLightParticleSystem = "dx_sun_clouds",
weather = "dx_rain_2",
weatherRadius = 2,
thunder = "lightning_bolt_hit",
thunderFrequence = 0.08,
clouds = "dx_clouds_grey",
cloudsFrequence = 9,
}
defineAmbiance{
name = "rainy_night",
stars = "dx_dark_stars",
skyLightColor = {0.6, 0.7, 1.0},
skyLightBrightness = 0.3,
clouds = "dx_clouds_dark",
cloudsFrequence = 8,
weather = "dx_rain_2",
weatherRadius = 2,
thunder = "lightning_bolt_hit",
thunderFrequence = 0.08,
}
- odinsballs
- Posts: 288
- Joined: Thu Dec 20, 2012 4:25 pm
- Location: south of heaven
Re: LotNR Project Official Thread [Open]
holy crap, nay double holy crap ,that is friggin awesome, even rain and such, aaaaaah its awesome, no but seriously its the stuff of genius. respect!
Re: LotNR Project Official Thread [Open]
We all know Diarmuid is secretly a genius who can speak 7 different languages, play every instrument and doubles as a secret agent.
Re: LotNR Project Official Thread [Open]
Diarmuid, does your rain fall across the entire map or just where the player is? I found it to be less demanding if you centre it around the player only.
Re: LotNR Project Official Thread [Open]
Hi,
So, a few pointers:
1. On weather
The rain is centered around the player. It's spawned on a per-tile basis, based on the weatherRadius parameter in the defineAmbiance. So if it's 2, you'll get a 5x5 area, with 3, a 7x7 area, and so on. When the party moves, a new row of fx are spawned at the end of the "weather radius square" in that direction, and the fx are destroyed on the back row of where the party moved from.
Code for moving wheater elements:
Wether FX are not spawned on wall tiles, or on "interior tiles". Interior tiles are automatically detected based on the presence of a roof object.
The system is flexible and will allow us to add snow, for example, or just simple fog, or whatever. For the rain you see, I made a custom 16 frame particle animation with photoshop, and Neikun tweaked it further.
2. On skybox
A lot of the techniques on the forum people tried were putting big elements far away and using negative depthBias to bring them to view. This caused a lot of clipping issues. The breakthrough was when I tought of doing the opposite: using a small element near the party, with positive depthBias to have it drawn behind other geometry. So the skySphere here is a unified color sphere around the party, about 1 tile big. It is a projectile, and moves at the speed of the party (thanks pferguso for pioneering that techinque). As it's a unique color (blue/grey) it doesn't matter if it's not perfectly in sync with the party. Actually what happens is that the first projectile is destroyed, then one shot in the direction, then when the party arrives, that moving projectile is destroyed and another static one is generated.
Code for creating/moving the skySphere:
3. On clouds
Clouds are large textured planes (about 20x20 tiles) which are created as static projectiles. They have a very slow rotation in their definition, which creates the moving cloud effect. The cloudsFrequence parameter determines how many clouds to create, but they are dynamically spawned with some randomness (on x, y & z axis), so you never get the same cloud coverage in a scene.
Code for creating clouds:
4. On global light
The global light is an fx high above, slightly off the party (in a diagonal adjacent square), with a great range. The fx is animated in sync with party movement.
Code for moving light with party:
5. On stars
Stars are a particle field, about 6x6x5 tiles wide. It's spawned above the player, with positive depthBias to be rendered behind clouds and architecture. There are some custom particles in there.
All the ambiances are switchable with setAmbiance(ambiance). For example, setAmbiance("day") or setAmbiance("night"). You see how it switches instantly in the video.
When ready (there's still a few issues to fix) we'll release this as standalone so that community can use this ambiance system.
EDIT: 6. On Projectiles
Aa you can see, I have a custom function for shooting projectiles that returns the id of the created projectile. Very useful for managing them afterwards. It scans the tile for existing items with a numerical (random) id, shoots the projectile, then rescans the tile for items with a numerical (random) id and returns the new one that just appeared. Here's the function:
So, a few pointers:
1. On weather
The rain is centered around the player. It's spawned on a per-tile basis, based on the weatherRadius parameter in the defineAmbiance. So if it's 2, you'll get a 5x5 area, with 3, a 7x7 area, and so on. When the party moves, a new row of fx are spawned at the end of the "weather radius square" in that direction, and the fx are destroyed on the back row of where the party moved from.
Code for moving wheater elements:
SpoilerShow
Code: Select all
function moveWeather(dir)
local dx, dy = getForward(dir)
local r = getAmbiance().weatherRadius
for w = 0, r * 2 do
wX = party.x - r * dx + (w - 2) * dy
wY = party.y - r * dy + (w - 2) * dx
if weatherObjects[wX.."."..wY] then
local weather = findEntity(weatherObjects[wX.."."..wY])
if weather then
weather:destroy()
end
weatherObjects[wX.."."..wY] = nil
end
wX = party.x + (r + 1) * dx + (w - 2) * dy
wY = party.y + (r + 1) * dy + (w - 2) * dx
spawnWeather(party.level, wX, wY)
end
end
The system is flexible and will allow us to add snow, for example, or just simple fog, or whatever. For the rain you see, I made a custom 16 frame particle animation with photoshop, and Neikun tweaked it further.
2. On skybox
A lot of the techniques on the forum people tried were putting big elements far away and using negative depthBias to bring them to view. This caused a lot of clipping issues. The breakthrough was when I tought of doing the opposite: using a small element near the party, with positive depthBias to have it drawn behind other geometry. So the skySphere here is a unified color sphere around the party, about 1 tile big. It is a projectile, and moves at the speed of the party (thanks pferguso for pioneering that techinque). As it's a unique color (blue/grey) it doesn't matter if it's not perfectly in sync with the party. Actually what happens is that the first projectile is destroyed, then one shot in the direction, then when the party arrives, that moving projectile is destroyed and another static one is generated.
Code for creating/moving the skySphere:
SpoilerShow
Code: Select all
function createSkySphere(level, x, y)
if getAmbiance().skySphere then
skySphereId = shootProjectileWithId(getAmbiance().skySphere, level, x, y, 0, 0, 0, 0, 0, 3, 0, 1, party, true)
end
end
function destroySkySphere()
if skySphereId and findEntity(skySphereId) then
findEntity(skySphereId):destroy()
end
end
function moveSkySphere(dir)
local dx, dy = getForward(dir)
local newX = party.x+dx
local newY = party.y+dy
destroySkySphere()
skySphereId = shootProjectileWithId(getAmbiance().skySphere, party.level, party.x, party.y, dir, 6.7, 0, 0, -dx*0.6, 3, dy*0.6, 1, party, true)
delay(0.5,
function(self, newX, newY)
if skySphereId then
findEntity(skySphereId):destroy()
skyScript.setSkySphereId(nil)
end
createSkySphere(party.level, newX, newY)
end,
{newX, newY}
)
end
function setSkySphereId(id)
skySphereId = id
end
Clouds are large textured planes (about 20x20 tiles) which are created as static projectiles. They have a very slow rotation in their definition, which creates the moving cloud effect. The cloudsFrequence parameter determines how many clouds to create, but they are dynamically spawned with some randomness (on x, y & z axis), so you never get the same cloud coverage in a scene.
Code for creating clouds:
SpoilerShow
Code: Select all
function createClouds()
local cloudsGrid = math.ceil(getAmbiance().cloudsFrequence)
for x = 0, cloudsGrid do
for y = 0, cloudsGrid do
local cloudsInterval = math.ceil(32/cloudsGrid)
local cloudsX = clampCoord(x * cloudsInterval + math.random(5) - 3)
local cloudsY = clampCoord(y * cloudsInterval + math.random(5) - 3)
local clouds = shootProjectileWithId(getAmbiance().clouds, party.level, cloudsX, cloudsY, 2, 0, 0, 0, 0, 9 + math.random() * 2, 0, 1, party, true)
table.insert(skyClouds,clouds)
end
end
end
The global light is an fx high above, slightly off the party (in a diagonal adjacent square), with a great range. The fx is animated in sync with party movement.
Code for moving light with party:
SpoilerShow
Code: Select all
function moveSkyLight(dir)
local dx, dy = getForward(dir)
local interval = 0.3
dx = dx * interval
dy = dy * interval
local fxTimer = timers:create(randomTimerId("lightTimer"))
fxTimer:setTimerInterval(0.05)
fxTimer:setTickLimit(10, true)
fxTimer:addCallback(
function(self, dx, dy)
local skyLight = findEntity("skyLight")
if skyLight then
skyLight:translate(dx,0,-dy)
end
end,
{dx, dy}
)
fxTimer:activate()
end
Stars are a particle field, about 6x6x5 tiles wide. It's spawned above the player, with positive depthBias to be rendered behind clouds and architecture. There are some custom particles in there.
All the ambiances are switchable with setAmbiance(ambiance). For example, setAmbiance("day") or setAmbiance("night"). You see how it switches instantly in the video.
When ready (there's still a few issues to fix) we'll release this as standalone so that community can use this ambiance system.
EDIT: 6. On Projectiles
Aa you can see, I have a custom function for shooting projectiles that returns the id of the created projectile. Very useful for managing them afterwards. It scans the tile for existing items with a numerical (random) id, shoots the projectile, then rescans the tile for items with a numerical (random) id and returns the new one that just appeared. Here's the function:
SpoilerShow
Code: Select all
function shootProjectileWithId(projName,level,x,y,dir,speed,gravity,velocityUp,offsetX,offsetY,offsetZ,attackPower, ignoreEntity,fragile,championOrdinal)
local pIds = {}
for i in entitiesAt(level, x, y) do
if i.class == "Item" and string.find(i.id, "^%d+$") then
pIds[i.id] = i.name
end
end
shootProjectile(projName,level,x,y,dir,speed,gravity,velocityUp,offsetX,offsetY,offsetZ,attackPower, ignoreEntity,fragile,championOrdinal)
for i in entitiesAt(level, x, y) do
if i.class == "Item" and string.find(i.id, "^%d+$") and not(pIds[i.id]) then
return i.id
end
end
end
Re: LotNR Project Official Thread [Open]
Very nice stuff Diarmund!
Only one note - Global light - I can see that city objects does not casting shadows - the "city street is flat" - othervise, the shadows will "will jumping during movement"... I gues that better solution is to use more lights to simulate propper daylight - It will take more time, but scene willl lok much better - for each level create aray and then spawn them in the environment.
Only one note - Global light - I can see that city objects does not casting shadows - the "city street is flat" - othervise, the shadows will "will jumping during movement"... I gues that better solution is to use more lights to simulate propper daylight - It will take more time, but scene willl lok much better - for each level create aray and then spawn them in the environment.
I'm the Gate I'm the Key.
Dawn of Lore
Dawn of Lore
Re: LotNR Project Official Thread [Open]
I originally created arrays of lights, but numerous shadowcasting lights slow down performance too much from what I've found. If we really wanted to, we could implement an option via keyboard (onGui) that could turn shadows on or off, but that's a bit too much for the time I have to put on this ambiance system, considering LoG2 is coming in some future...Leki wrote:Very nice stuff Diarmund!
Only one note - Global light - I can see that city objects does not casting shadows - the "city street is flat" - othervise, the shadows will "will jumping during movement"... I gues that better solution is to use more lights to simulate propper daylight - It will take more time, but scene willl lok much better - for each level create aray and then spawn them in the environment.
Re: LotNR Project Official Thread [Open]
Oh, that's interesting - I used "local lights" to lighten my ToW village and it was ok. I used nonshadow light for brightness and small no crossed lights to create shadows - with smart scene architecture you can get good results without performance issues...
But I left that because distribution of light was strange - It was ok for village, because you can set up environment - I menan design streets in proper way, but open areas like "castle enterance"... in 45° top left free look camera you will get darkness in the viewport, however distance is 5 cells in front (7 is max) and 3 left (with open areas 3 cells left and right is "normal", you cannot create smaller open area) 45° front top, you will get darkness in object higher than 6m etc...
But I left that because distribution of light was strange - It was ok for village, because you can set up environment - I menan design streets in proper way, but open areas like "castle enterance"... in 45° top left free look camera you will get darkness in the viewport, however distance is 5 cells in front (7 is max) and 3 left (with open areas 3 cells left and right is "normal", you cannot create smaller open area) 45° front top, you will get darkness in object higher than 6m etc...
I'm the Gate I'm the Key.
Dawn of Lore
Dawn of Lore