Jump to content
Eternal Lands Official Forums
Roja

Skybox discussion

Recommended Posts

ttlanhil:

 

I only have a sky that reflects time of day and has stars and clouds. Let me hack in a sun and moon, make a generic rock sky for caves, turn off sky for houses, and tweak the sky color a bit for sunset and sunrise and hook the weather to change cloud cover. Then I'll let you know.

 

Once I'm there It'll be ok. The reflections aren't reflections yet (They're just the bottom of the sky spheres). Eventually I'll use a stencil to make them look right.

 

I won't be doing any of that until I merge my changes with the new client. I'm going to set them up with defines and everything. ( I was too lazy when I started, and it became a difficult task before I knew it. I've hacked at over half the files so far. )

 

If it gets to be too long I'll just release a version to you that isn't too ugly (say 2 more weeks).

 

Roja:

 

Yea, that's me. Somehow an interest in MIDI music (I'm a singer who can't play piano. How sad.) morphed into an interest in computers, which, combined with a fascination with the demoscene (Yay Future Crew), led me the wrong way into computer programming. I found an outlet in Computer Graphics only to discover that people thought I was good at math. Hahahahahahaha! I wasted a full year of post-graduate studies making a recording with this group and going to competition with them.

Share this post


Link to post
Share on other sites

Just a note on the cavern ceilings & house insides.

 

To save on space, we've often times combined both on one map. So areas have caverns, and other areas have house insides, all on the same map.

 

Can we define an area in the map, minX,minY, maxX, maxY, that show a particular "sky", or none at all?

Share this post


Link to post
Share on other sites

To save on space, we've often times combined both on one map. So areas have caverns, and other areas have house insides, all on the same map.

 

Can we define an area in the map, minX,minY, maxX, maxY, that show a particular "sky", or none at all?

 

In post 22 on this thread I suggested using a system like the one for sound to manage sky definitions for maps. I still think this would be the best plan.

 

Going even further, I think that a basic portal system would be a good idea for interiors maps (It might make places like Tarsengaard Magic School more friendly to fpv play). I have noticed that several interiors show a noticeable reduction in framerate in certain directions in fpv, probably those with lots of out of sight interiors, most notably (to me) the storage in portland: the slow down happens when you face into the room from the door making fpv nearly useless. Sound, sky, and portal maps could all be handled similarly (except that portals may need polygons, not boxes) and should sooner or later be incorporated into the map editor if sound isn't already. There would be no need to include these polygons in the map files, they could be stored separately just as sound is now. For now I'll make it so that if no sky is defined for a region on a map, no sky is shown, or a default colour is shown. For the sake of those who use traditional views and to keep water looking good I propose blue.

Share this post


Link to post
Share on other sites

I should have used the word cells. Cells and Portals are a visibility technique to be used together with frustum culling (which we already have). Basically they involve defining regions of a map that are relatively enclosed and have only a few small "portals" through which you can see other parts of the map. When a portal is visible you use its edges (or a rectangle around its edges) to define a new frustum that lets you see into the space beyond. Maps like the Tarsengaard map are ideal candidates for this.

 

As a first step, when we define a system for choosing what parts of a map get what sky we also create a rough kind of cell. All the geometry inside the cell becomes a mini-map and gets its own storage in memory separate from all the other little cells on the map. Some of the doors (and maybe archways) in that map can become portals. This will reduce what needs to be culled and reduce what is rendered that shouldn't be seen anyhow. The reduction in what is culled is important. I've noticed that the culling step can cut frame rates by over 5fps on busy maps. Comparing 1000's of objects against 8 planes at the cost of several math operations can be time consuming. Having smaller sets to compare against, or some predefined way of completely ignoring huge amounts of scenery with a minimum of fuss is a big advantage.

 

See this link, starting on page 19.

 

We don't actually need the portals to start, just the cells. We may never wish to use portals because lining up ceilings and walls may be problematic. Using boxes or polygons to section off independant parts of maps would eliminate some slowdowns that don't seem to make sense.

 

Any further discussion belongs in LOD, even though it is tied to skyboxes. By sectioning maps into sky regions we define a perfect candidate for a scene complexity management strategy.

 

 

PS

At the end of that presentation is a quick case for the use of distance sorting of primitives/scene elements (not polygons) combined with occlusion culling to improve performance. That technique is used, with a hardware assist - GL_[ARB|NV]_occlusion_query, in games like Serious Sam 2.

 

edit: trying to make sure it all makes sense.

Edited by emajekral

Share this post


Link to post
Share on other sites

I'm still here!

 

I'm doing my best to hack at all the projects I've taken on, but between two jobs and kids I can't go very fast.

 

I'm going to post here because I have pretty pictures , but there's stuff relating to fpv and lod.

 

Pretty Pictures First:

 

RosyDawnWithMoonAndStars.jpg

 

CloudyDay.jpg

 

UnderworldFlames.jpg

 

LOD:

I've finally decoupled near and far planes. In third person the clipping planes have their old behaviour. In FPV there's an adjustable far plane and a fixed near plane.

 

I get the best boost by far from playing with clipping. That frustum does good work.

 

Bad news: The frustum doesn't seem to cull reflections properly. I'm going to look into that soon.

 

Cells will have to wait. The complexity of the project is beyond me for now. I don't have enough cycles to spare. :D

 

FPV:

The middle mouse button toggles between mouse look and GUI mouse modes now.

Switching to chat or map views also gives you GUI mouse and switching out puts you back in whatever mode you were in before.

 

Bug: I'm chasing down a bug where switching between mouse look and GUI mouse causes jumping. SDL_WM_GrabInput triggers a mouse motion event the size of the distance from your cursor to the middle of the screen. I can't consistently catch it, and some developpers claim whether its generated is implementation dependant. On my machine the bug only present in full screen mode.

 

Sky:

New Stuff

  • Clouds have time of day colors and reflect lightning.
  • The sky has sunsets.Colors are a compromise between classic EL and some selected photographs.
  • There's a horizon fog faker to reduce popping and bad far plane culling effects. (Real skies have foggy horizons anyhow. I've consulted photos and maybe burned a few too many lawns while at my second job.)
  • There's a moon. I still haven't decided how it'll move, or if there'll be two. I need a better texture for it. It's implemented as a sphere, so we can probably do lunar phases.
  • I'm using a stencil buffer hack to do sky reflections. If you pay close attention in Silly Songs with Ezzat you'll see that the clouds move in different directions in the water and sky. If you are only looking down or up it isn't a problem. That's fixed but only if there's a stencil buffer available, otherwise you get the old behaviour. Someone with more time can work on that someday, I'm sure.
  • The underworld has a flaming sky. It's animated. It sits above a yellow lake of fire. Perhaps yellow isn't the best choice (the magma in the underworld is reddish).
  • Stars have 3 brightness levels. (For the astronomers out there the stars have 3 magnitudes of brightness :lurker: ) They also fade smoothly with time of day.

Under construction:

  • Sun
  • Make moon opaque to stars AND still have it take on sky hue during day (stencil buffer)
  • Moon halo and cloud effect (more stencil buffer magic)
  • Moon motion - suggestions please: Always opposite sun, slightly faster than sun or slightly slower; always shows same face or rotates slowly, etc.
  • Variable cloud levels. This will need to be coordinated with NEW_WEATHER. For now I'll hook the two cloud layers into foggy and rainy weather somehow. Haven't looked there yet.

 

Compromises:

  • In the absence of cells the sky will come in three flavours:
    • Outdoors - reflected cloudy sky
    • Indoors - black above, blue below... for water
    • Underworld - flaming sky, lake of fire

    [*]It will be hooked into the dungeon flag. I plan to intercept the word Underworld in a certain message to trigger the Underworld sky. It will turn off when a new map is loaded. That is unless there's a better way...

Share this post


Link to post
Share on other sites

like... dude... :icon13: woah-and-stuff

Cells will have to wait. The complexity of the project is beyond me for now. I don't have enough cycles to spare. :D
not to put more work on you, but what would you think of a ray-trace type draw? if you can't directly see the square( or tile, coord, etc), don't show it... or maybe allow some bends... with the current EL landscape 2D would be enough... depending on the 3D storage/mapping (no, I don't know the details), it may be more efficient inside. small rooms especially, but to a lesser degree caves and castles
Bug: I'm chasing down a bug where switching between mouse look and GUI mouse causes jumping. SDL_WM_GrabInput triggers a mouse motion event the size of the distance from your cursor to the middle of the screen.
are there ways to avoid it? disable mouse tracking, run event, reenable... warp the mouse to the position manually before grabbing it, etc?
[*]There's a moon.[*]I'm using a stencil buffer hack to do sky reflections.[*]Stars have 3 brightness levels.[*]Moon motion - suggestions please: Always opposite sun, slightly faster than sun or slightly slower; always shows same face or rotates slowly, etc.

[*]Variable cloud levels. This will need to be coordinated with NEW_WEATHER. For now I'll hook the two cloud layers into foggy and rainy weather somehow. Haven't looked there yet.

how feasable is it to load these from XML? also, have you done any locational adjustment to the skyscape? (a while back I played around with having irilion sunrise/sunset/etc a half-hour out from seridia, as well as an adjustment for shorter/longer days, which was fun to see (especially if you say irilion is far south and seridia far north). we'd need a global-to-continent-coord scale, as well as continental positions, to do this, but I doubt that'd be a major issue)
I plan to intercept the word Underworld in a certain message to trigger the Underworld sky. It will turn off when a new map is loaded. That is unless there's a better way...
maybe based on the map number, or even a format chage for mapinfo.lst so you can set the sky-type (far easier than changing the elm format)

Share this post


Link to post
Share on other sites
Cells will have to wait. The complexity of the project is beyond me for now. I don't have enough cycles to spare. :D

not to put more work on you, but what would you think of a ray-trace type draw? if you can't directly see the square( or tile, coord, etc), don't show it... or maybe allow some bends... with the current EL landscape 2D would be enough... depending on the 3D storage/mapping (no, I don't know the details), it may be more efficient inside. small rooms especially, but to a lesser degree caves and castles

Ray tracing is teh slow. I know how, but for good visibility in real time I have to ray cast for every pixel. Maybe this can be done in hardware, but I have to process the whole scene for every pixel separately. I know the guys at the ATi and nVidia do hardware ray tracing with shaders... maybe there are tricks they use that make it easier. I don't know. I'd have to look into it...

 

The frustum is doing a terrific job mostly, there's just some times where there's a really obvious clip that it's just too dumb to know about. Cells are relatively easy: make xml for describing boxes on the map. In the client load the xml with the map. Use cell numbers and an inside/outside/intersecting test to either sort cell contents into multiple render lists or add a cell_number tag to objects in the main render lists. I just don't have time for them.

Bug: I'm chasing down a bug where switching between mouse look and GUI mouse causes jumping. SDL_WM_GrabInput triggers a mouse motion event the size of the distance from your cursor to the middle of the screen.

are there ways to avoid it? disable mouse tracking, run event, reenable... warp the mouse to the position manually before grabbing it, etc?

Yes. Move to a grabmouse only interaction model. The client takes full control over tracking the mouse's current position and decides when to ignore that information itself. So far that's been more tweaking than I wanted to do, but it looks necessary. BONUS: that will enable full color cursors for all interactions.

how feasable is it to load [the sky] from XML?

That was the original plan. I don't know XML (except in a vague XHTML, related to LaTeX, its a data tagging language kind of way. I imagine it would be simple enough to get into if I needed to... but I'm trying to relearn x86 assembly so I can teach it). I was going to make a generic sky that could be reconfigured with a set of related function calls. I was hoping eventually to make it so that it would switch its type based on bounding boxes like the music in the game. That way maps with multiple sky types could have appropriate skies for each location. Those were to be stored in some text based format like XML. I also figured sky cells could be used to do rudimentary quick visibility stuff.

also, have you done any locational adjustment to the skyscape? (a while back I played around with having irilion sunrise/sunset/etc a half-hour out from seridia, as well as an adjustment for shorter/longer days, which was fun to see (especially if you say irilion is far south and seridia far north). we'd need a global-to-continent-coord scale, as well as continental positions, to do this, but I doubt that'd be a major issue)

Light_level could be hacked such that it can be adjusted for different day lengths. That could then be exposed in the XML interface for skies. No prob. One would have to do something like that for generic programmable skies anyhow.

I plan to intercept the word Underworld in a certain message to trigger the Underworld sky. It will turn off when a new map is loaded. That is unless there's a better way...

maybe based on the map number, or even a format chage for mapinfo.lst so you can set the sky-type (far easier than changing the elm format)

:icon13: Duh. I forgot about that. I got too focused on doing sky switching inside maps. I forgot that I could switch on filename - if needed. I'll work on that. It'll be a hack though: underworld is the only exception. There's a perfectly good sky/dungeon flag to use for everything else. I'll look into mapinfo.lst and see about that.

Share this post


Link to post
Share on other sites

Wow looking great! Awesome job! Don't worry about moving slowly. It's good to get any movement at all in this area :P

 

It would be really nice for another programmer to help you out with the cells. I know there's not many around here, but if someone else can pick up that project it'd be a great help! :)

Share this post


Link to post
Share on other sites

Looking really great!

 

And ohh, regarding the Moon. There are two of them, one larger and one smaller.

The larger moon is called Macuma, or simply, "the moon". The smaller moon is less visible and is called Kaifhi. The two moons circle the sky in a seemingly erratic pattern. The average citizen knows that the moons are used by the gods to balance the magic stream of Draia.

Edited by Derin

Share this post


Link to post
Share on other sites

Awesome does not really describe the screen shots you posted. Its GREATTTTT!

 

Regarding the moon(s), one thing i like to point at, is, we used the phrase "the moon turns red" in some contests, which sounds somehow that the red colour is caused by the atmosphere, and so both moons should turn red. Or, we have only one moon..

 

Whatever, im just pointing at this :P

 

Piper

Share this post


Link to post
Share on other sites
I plan to intercept the word Underworld in a certain message to trigger the Underworld sky. It will turn off when a new map is loaded. That is unless there's a better way...

maybe based on the map number, or even a format chage for mapinfo.lst so you can set the sky-type (far easier than changing the elm format)

:D Duh. I forgot about that. I got too focused on doing sky switching inside maps. I forgot that I could switch on filename - if needed. I'll work on that. It'll be a hack though: underworld is the only exception. There's a perfectly good sky/dungeon flag to use for everything else. I'll look into mapinfo.lst and see about that.

 

Just thought about this today, I hope you know that there is also hell in c2 that will probably need the same sky. So there would be 2 exceptions. I'm sorry if you thought about this already :rolleyes:

Edited by Cycloonx

Share this post


Link to post
Share on other sites

Got it. ;)

 

Don't know how active this thread is, but in case anybody wants any formulae for celestial bodies, here you go:

 

Declination: AxialTilt * -cos((DaysFromWinterSolstice / DaysInYear) * (2 * Pi))

Sunrise (in seconds): SecondsInDay / 2 - SecondsInDay * acos(-sin(Latitude) * sin(Declination) / (cos(Latitude) * cos(Declination))) / (2 * Pi)

Sunset (in seconds): SecondsInDay * acos(-sin(Latitude) * sin(Declination) / (cos(Latitude) * cos(Declination))) / (2 * Pi) + SecondsInDay / 2

TimeAngle: (CurTimeSeconds + SecondsInDay / 2) / SecondsInDay * (2 * Pi)

SunAltitude (angle upwards): asin(sin(Latitude) * sin(Declination) + cos(Latitude) * cos(Declination) * cos(TimeAngle))

Sun Azumuth (angle horizontal): asin(-cos(Declination) * sin(TimeAngle) / cos(SunAltitude))

 

The color of the sky is mostly due to Tyndall scattering, which means that as light passes through the atmosphere overhead, some of it scatters and ends up reaching you, giving you light where normally they would normally just be blackness. In a given atmosphere, certain colors will scatter better than others -- in our case, blue and purple scatter best (the reason the sky doesn't look purple is due to our eyes). The sky is orange at sunset near the sun because so much blue has scattered from it by the time that it gets to you that there's not much blue left in it.

 

Do you need a formula for determining the color at a given point in the sky when the sun is in a given position? Also, do you need formulae for the position of the moon? I'd be glad to help. :cry:

Edited by KarenRei

Share this post


Link to post
Share on other sites

Seems like the thread is not very active, but may I suggest you try to contact emajekral to see what the status is.

 

Also, do you need formulae for the position of the moon? I'd be glad to help. :)

Just remember that there are two moons, one bigger and one smaller.

For the calendar see: http://www.eternal-lands.com/page/calendar.php

For the moons, see: http://www.eternal-lands.com/page/moonsigns.php

Share this post


Link to post
Share on other sites

Seems like the thread is not very active, but may I suggest you try to contact emajekral to see what the status is.

 

Also, do you need formulae for the position of the moon? I'd be glad to help. :blink:

Just remember that there are two moons, one bigger and one smaller.

For the calendar see: http://www.eternal-lands.com/page/calendar.php

For the moons, see: http://www.eternal-lands.com/page/moonsigns.php

 

 

Equations noted. Not much time to work with them. Some exist in simplified form already... Sun position for example. Moon is currently implemented in a different manner, but I may switch over. I am open to trading off the sky code if someone wants to give it a go. It has very few comments at the moment though.

 

To whoever works with light, sky colors, and sun position: I found code that did most of that stuff in lights.[ch] and used it. That may or may not be the best place for it, but I was trying not to completely overhaul the game.

 

Video with much of the work to date is here, also posted in response to lighting questions in another thread. I captured the video at too high a resolution so many fine details are lost, but I don't have time to redo it. :)

 

Also featured is some of the LOD work that Learner has been sharing with me. I'm getting some decent framerates in MM and other complex maps thanks to some clever object adjustments and size dependent culling. (Learner: I promised a video of how FPV and EL_NEW_OBJECTS work together... here you go. Yeah, I know not the best demo for that.)

Share this post


Link to post
Share on other sites

Thank you. Things will look even better with the magic effects Octane and Kindar Naar have been working on. Add that to the current pace of server work and, well... Wow!

 

Speaking of server work... cloud cover, and moon positions/effects may require a server side component - the latter especially because lunar movements are described as erratic and some have asked for "red moon" events. I'm not ready for detailed discussion, but if someone wants to do the thinking for me or for a future developer I wouldn't mind.

 

What I am thinking of is that at login and once a day, preferably when the moons are below the horizon, new moon positions are sent to the client. They could be sent as polar coordinates relative to the sun. Also weather-like signals could be sent to allow lunar signs to coincide with events.

 

I have only a limited understanding of what signals are sent to control weather events, so if there are ways for the client to determine conditions such as clear skies, lightly cloudy, cloudy, overcast, and low fast moving clouds (possibly with a direction of movement) it'd be nice to know them. Right now I can do partly cloudy most of the time, and cloudier when it rains - but the transition is abrupt.

Share this post


Link to post
Share on other sites

with rain, there's about 90sec, from memory, warning before it starts/stops, but that's about all the control there is

 

and I'm itching to plug it all into a test client, do you think it'll be ready for a wider beta test soon? if now, is the patch uptodate?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×