Jump to content
Eternal Lands Official Forums
Roja

Skybox discussion

Recommended Posts

Post here discussion on creating a sky for EL.

 

My thoughts:

 

If we are to do it, let's do it right and make it look good.

I don't know much about this stuff, but there are the things I assume we may need to have:

 

Sky layers

1. color that fades into different colors depending on the times of day/weather.

2. Clouds-have different types of clouds

3. stars at night

4. sun & moon

 

 

Examples of the type of sky we should aim for:

http://www.kehlet.cx/articles/55.html

http://0x44.com/postline/cd/jpgs/IyHhl4JeR...9AmfmgVhQh5.jpg

 

Example of a sky we don't want:

http://www.freeworldonline.com/sshots_archive.php?v=102

http://www.freeworldonline.com/sshots_archive.php?v=80

Share this post


Link to post
Share on other sites

What do you guys think about putting a lot of 512 textures together to make the clouds look good, instead of procedurally making them? I dont know how complex the programming is..but I assume to make it look good it has to be quite complex.

 

The only problem/challenge then would be the color of the sky in regards to the textures with the lighting and such.

Share this post


Link to post
Share on other sites

Copied over from Camera freedom thread:

 

That shot was from following this article and applying the generated texture onto the quad which is currently the sky. When I started looking into sky domes/planes I got a dome drawn but no textures applied so i'm not sure how useful that code will be.

 

Looking at the article, and the related Perlin Noise pages; it seems quite a complicated way to get the desired results. Generating fractal or self-similar noice with a given set of properties can be done much cheaper with 2D Fast Fourier Transform (FFT).

  1. Generate a white noice complex image (just a rand output would do).
  2. Shape the noise with a radial function (1/r for brown noice). You can tune the function to find the best results. (This step can be done during (1)).
  3. Perform an FFT and take the absolute value to give the image.

FFTs and point-wise multiplication are cheaper than convolution at relatively small image sizes (the quoted papers are performing convolutions long-hand in places).

 

The FFT algorithm can be extended to work on any number of dimensionality of data (applying it along each dimensional axis, taking the conjugate before moving to the next axis).

 

This will produce an image which wraps (it can be smoothly tiled). If this is not desired, then take a larger starting image and use a subsection.

 

Simple noice models would require some additional work to create realistic clouds (especially if you are creating them as directly as a 2D image).

 

Other approaches could include using cloud wavelets to build up patterns.

 

----

 

clouds2.png

Sample cloud pattern using k=2 generated using Octave

Sample cloud pattern generated from shaped gaussian noise and Fourier transform, thresholded at 50% coverage. Lower values of k are dominated by small scale structure, where k=0 is white noise. Larger values of k are dominated by larger scales.

 

The Octave (Matlab) code used to generate this image is as follows:

% random complex noise, gaussian profile
A = randn (512,512) + i * randn (512, 512);
A (1,1) = 0;
% radial function aligned for Fourier transforms
R = fftshift (ones (512,1) * [0:511] - 256)/512;
R = (R * R').^0.5;
R(1,1) = 1;
% Apply the radial function, transform, and take magnitudes
B = abs (fft2 (A./(R.^2.0)));
% threshold at the mean, so half image contains "clouds"
B = B - mean (B(:));
B (B<0) = 0;

Since this is just a 2D model, it does not capture the 3D structure of clouds, and the assymetry due to viewing angle. It is reasonable for a "look straight up" (or down...) simulation of clouds.

 

Adjacent values of k (1.5, 2.5) do not have as "cloudy" a structure, so for the simple radial shaping k=2.0 is as good as it gets. Alteratives are to use more complex radial functions, which includes multifractals.

 

On 'k':
I am using a simple interpretation of the fractal dimension k, which is not correct according to literature, but is appropriate for its use here. That said, the definition of k varies depending on the source anyway...

 

Second Post:

 

A couple of thoughts this morning:

Firstly, I'll try using a gaussian shaping of the noise, which will give a range of larger scale structures to the final image, which may look better.

Didnt work well; the resulting images look more like the surface of a brain than clouds.

Second...

We don't need to generate cloud images at run time at all!

Provide a few cloud images with the client. The current cloud pattern is then described as the weighted sum of two or three of these patterns, and some threshold to give cloud cover. Since the images are self similar patterns, they should add cleanly.

 

The advantages of this approach:

  • Everyone sees the same sky (on the same map).
  • Low runtime cost.
  • The cloud images can be adjusted to show realistic perspective changes towards the horizon.

The information needed for the sky clouds can be packed into two bytes if you are particularly sadistic:

typedef struct 
{
unsigned int image1 : 4;	/**< ID of first image map, 16 possible images */
unsigned int image2 : 4;	/**< ID of second image map, 16 possible images */
unsigned int weight : 4;	/**< weight of image2, in 16ths, weight of image1 is 1 minus this weight */
unsigned int cover : 4;	/**< sky cover in 16ths, by thresholding the combined image */
} cloudpattern_type;

Actually, you could get by with 3bits for weights and covers in 8ths, and allow 5bits for 32 base images (or 33 if you are a real pedant).

 

This allows you to have gradually changing patterns, by increasing the weight from 0..15, the cloud pattern changes from one to another. This could be used to simulate cloud movement.

Cloud Movement:
If we have 16 basic images, consider them arranged in a 4x4 grid (wrapping top and bottom). Adjacent images are similar; shifted by compass direction a small amount, plus a random variation. If you want the clouds to appear to move NE, then select
image1
as
C[m][n]
and
image2
as
C[(m+1)%4][(n+1)%4]
, and keep incrementing the
weight
from 0 to 15.

Unfortunately, if the start and end images are too similar, the result can end up being blurred. If they are too dissimilar, then there is no illusion of movement. I don't think giving the illusion of cloud movement will work very well.

Most other celestial objects are deterministic enough to be handled by the client (star patterns, moons, planets, the sun(s)). Drive these by the date and time.

 

Exotic items like comets, meteor showers, if desired, would have to be driven by the server as events.

Edited by trollson

Share this post


Link to post
Share on other sites

clouds2a.png

A more artistic rendering of the Clouds image posted above

I though that the simulated noise image I posted above may be a bit abstract for those not familier to simulation and modelling. So I've tarted up the image to make it a bit more rememisant of clouds in the sky. Added a coloured background gradient to represent blue sky fading into the horizon, and adjusted the colour map of the clouds to give an impression of them being backlit. This was all done with GIMP on the image pulled down from the posting above.

Share this post


Link to post
Share on other sites
"done in gimp"....but can you make it look like that in the game?

If the sky can be composed by layering images with alpha channels, then that all I did with Gimp for display.

 

I don't think it there is any actual need to simulate clouds on the client though, as I describe above. So some stock images which can be merged for variety should give the right illusion.

 

Damn! You can't add together the cloud distributions and expect the result to be another cloud distribution. What you get is something more blurred, and we want to keep the same level of cloudy-ness. (BTW, this is a different problem to collaging cloud samples together; that is still doable!).

You can do it in the Fourier domain, by combining the original gaussian noise. This is demonstrated in the following sequence:

cloudseq1.png

Cloud sequences generated by weighted sums in the Fourier domain

The above represents an interpolation of cloud formations between the start and end frame. The interpolations are done in the Fourier domain, by weighted sum of the two complex gaussian noise images. This sequence also demonstrates how the cyclic nature of the FFT generates images which wrap (ie, can be tiled).

Edited by trollson

Share this post


Link to post
Share on other sites
"done in gimp"....but can you make it look like that in the game?

If the sky can be composed by layering images with alpha channels, then that all I did with Gimp for display.

 

I don't think it there is any actual need to simulate clouds on the client though, as I describe above. So some stock images which can be merged for variety should give the right illusion.

C'est exact.

 

Sphere + texture + inverted normals = sky sphere.

 

A, B : Two spheres with clouds, with patterns generated in Gimp or Photoshop ... this is done in the old Quake games.

 

C: One sphere with stars that fades in at dusk and out at dawn.

 

D: One billboard that tracks the sun used in shadows.

 

E: One Billboard that has the moon that follows some track I don't know yet.

 

F: One Sphere that has Sky colour.

 

G: One cylinder that has fog coloured haze that fades to Sky colour. (May be integrated with F as a Height vertex colour function.

 

 

At some large distance, with huge spheres Centered on player

Render in order: no_alpha( F+G ) + alpha( C ) + alpha( D )to allow a glow + no_alpha( E )so that moon covers sun + alpha( A) + alpha( B )

 

Spheres with clouds can fade in to allow clear skies, or they can have one blue hemisphere and clouds can rotate to travel beyond horizon. Continuous cover is achieved by having the spheres rotate at certain relative speeds. Care needs to be taken that the degenerate point at each pole of the spherew is not obvious. This is an artwork issue. I'm pretty sure this pattern will work in reflections and regular rendering.

 

Using one cloud texture, some surfaces, alpha blending, and gl's glColor*() functions I'm pretty sure one can make clouds that look like this (3 layers: cloud, shifted red tinted cloud, blue)

 

clouds.jpg

 

removing the red tint gives this:

 

clouds2.jpg

 

I'm hacking together a module to handle this. I seem to be having some troubles with openGL's states though, so I may take a while. If I get it done, expect sun tinted clouds, haze on the horizon (and maybe sunset colors), sun, moon, and stars.

 

There will be no cloud shape evolution though. I'm not about to rise above cheap hack level on this one. Sorry. Maybe one of the other efforts will work and we can plug it in. :)

 

(Sorry Roja, I didn't look at your pictures before posting, I'll leave it here, but...)

Edited by emajekral

Share this post


Link to post
Share on other sites

Would there be an (appearance) advantage in having two cloud spheres?

 

Distant cloud sphere: Representing clouds to the horizon, with a vertical axis of rotation.

 

Near cloud sphere: "Behind" the distant cloud sphere, representing overhead clouds, with an arbitary axis of rotation.

 

 

For that matter, what level of "realism" do we want to achive? I am wondering whether we should just use a few painted clouds rather than generated ones, especially if we don't need any pseudo-animation (other than colour filters).

Edited by trollson

Share this post


Link to post
Share on other sites

Those clouds don't look bad emajekral, although we'd still have to see what they look like in game.

 

Ok, a few questions:

 

-If we use pre-painted cloud textures, my only concern is will/can they reflect some of the sun color?

 

-Using any type of cloud .bmp image texture, would it just be 1 512 texture on the entire sphere, and only that one, always? Or can there be many 512 textures on a single sphere(lined up both horizontaly & vertically like a grid to give a better resolution? Also regardless if there is one or many texture groups of the clouds, can that texture/texture group, be changed? Like fade into a different texture or texture group?

(such as storm clouds vs. nice sunny day clouds).

Share this post


Link to post
Share on other sites
-If we use pre-painted cloud textures, my only concern is will/can they reflect some of the sun color?

Reflect dynamically in response to the sun position? Not easily or well.

 

There needs to be additional information to say which parts to highlight/darken for different sun positions; which I would expect to come from a model rather than artistry.

 

It may be acceptable to paint clouds for one sun position, flip them for variation (two clouds for the price of one), and rotate according to the current sun position. Not effective if you expect people to sit watching the clouds for hours though.

 

If there is a selection of clouds (with alpha channels) then they could be combined, overlapping, to fill the sky sphere (rather than tiling images).

 

Looking at the sky in the Morrowind screen shots, which are very nice; it looks like a painted sky -- I can't see any ground shadows, so is there a sun?

Share this post


Link to post
Share on other sites

yeah morrowind has a sun/moon/stars.

 

It's possibly they have a huge ton of pre-painted cloud textures that correspond to the sky color at the time. Their game size is large enough. If that's the case then obviously we can't compete in that area.

Share this post


Link to post
Share on other sites

i would hazard a guess that they do it more or less like what emajekral talks about. multiple layers where one fades between a blue sky and a black sky with stars, another where the sun and moons (i kinda recall the EL planet having more then one) moves about, and yet another where the clouds are added.

 

for the clouds, could one do something similar to the basic clothing color of the characters? in that the cloud shape is based on a "height map" and then rendered, complete with a red tint for when the sun is low?

 

given that the sun's path over the sky will most likely be hard coded, the same data can be used to render the surface of the clouds and so on. and all hooked into the ingame time of day.

Share this post


Link to post
Share on other sites

i would hazard a guess that they do it more or less like what emajekral talks about. multiple layers where one fades between a blue sky and a black sky with stars, another where the sun and moons (i kinda recall the EL planet having more then one) moves about, and yet another where the clouds are added.

 

for the clouds, could one do something similar to the basic clothing color of the characters? in that the cloud shape is based on a "height map" and then rendered, complete with a red tint for when the sun is low?

 

given that the sun's path over the sky will most likely be hard coded, the same data can be used to render the surface of the clouds and so on. and all hooked into the ingame time of day.

 

You're getting dangerously close to volumetric shadows there. The technique I suggested is a simplification of a volumetric rendering process, but it is too simple and very hackish.

 

I'm guessing that the major projects are now using volumetric shadows.

 

I have some cg code snippets, paper references, and commentary in nVidia's Graphics Gems somewhere in my office. I have no idea how hard the system is to implement, or how much tuning is required for performance, but... hold on... they say

Volume rendering performance is largely influenced by the complexity of the fragment shader... lookup tables[, stored in textures,] may be faster than [complex] fragment programs... texture reads, however, can result in pipeline stalls reducing rendering speed. Achieving peak performance requires finding the correct balance... which can be a challenging profiling task.

 

As if the implementation itself wouldn't be bad enough. But if we get em, they sure are pretty, and can have very complex light interactions - they can be lit by multiple sources using BRDFs.

 

For clouds the idea is this: store low detail shapes in a 3d tex map, and perturb them with a small procedurally generated and animated noise texture volume. Light using a custom fragment shader/light table.

 

Lookit the pretty:

 

volClouds.jpg

 

This cloud technique would be icing on the cake. A basic cloud system is needed for those without shader capable GPUs.

Share this post


Link to post
Share on other sites

when i wrote height map i may have used the wrong words.

 

i had the images trollson produced in mind. basicly a 2d image that using grayscale or similar gives diffrent parts of the image diffrent "heights", and then based on that a rising or setting sun effect is added using said height data to add the shade of red wanted.

 

that way the clouds are basicly a 2d image, but will get the effect of 3d.

 

or we may well be talking about the same thing. i have thing image in my head about the end result, but i dont know the technical terms and so on.

Share this post


Link to post
Share on other sites

Question(for the texture clouds proposal that emajekral originally showed here):

 

-Using any type of cloud .bmp image texture, would it just be 1 512 texture on the entire sphere, and only that one, always? Or can there be many 512 textures on a single sphere(lined up both horizontaly & vertically like a grid to give a better resolution? Also regardless if there is one or many texture groups of the clouds, can that texture/texture group, be changed? Like fade into a different texture or texture group?

(such as storm clouds vs. nice sunny day clouds).

Share this post


Link to post
Share on other sites

Question(for the texture clouds proposal that emajekral originally showed here):

 

-Using any type of cloud .bmp image texture, would it just be 1 512 texture on the entire sphere, and only that one, always? Or can there be many 512 textures on a single sphere(lined up both horizontaly & vertically like a grid to give a better resolution? Also regardless if there is one or many texture groups of the clouds, can that texture/texture group, be changed? Like fade into a different texture or texture group?

(such as storm clouds vs. nice sunny day clouds).

 

Yes, if resolution is a concern many 512 textures could be used, either one texture tiled, or many stitched together for greater variety. Texture memory becomes an issue if we try to do too much.

 

As for changing weather... I'm sure something could be hooked into the existing weather lighting and fog system that could cue cloud cover changes. If we're okay with fading from one cloud type to another then it's a matter of tracking which clouds are being displayed, loading the new clouds into the inactive ones and then fading over. I think. I've been busy suffering from heat exaustion so I'm not too thinking too clearly.

Share this post


Link to post
Share on other sites

I was thinking of a few different textures stitched together for variety.

 

It'd be easiest if they go together in a special order for the type of sky, and not just randomly. The only thing I'l have to worry about is them tiling with the next type of sky cloud group, which shouldn't be a problem.

 

We can have a few cloud groups, like:

-3 groups of "nice day" clouds

-3 groups of "stormy clouds"

etc.. to give variety

 

How many tiles and how much we can stretch them(as i'm sure we can get away with making the 512 texture be stretched bigger), depends on the skybox and how it'll look in the game-so that would be a trial and error thing.

Share this post


Link to post
Share on other sites

I personally think adding a sky to EL would be a great idea! The current camera view has always annoyed me to death, for example when you are hunting a random spawning animal you never know if they are close to you or not!

 

A nice sky combined with the camera view the other guy made would greatly increase the enjoy playing. :D

Share this post


Link to post
Share on other sites

From the other thread:

Notice the visit to the underworld; this really would be helped by a fiery cavern roof.

 

Whats the best way to handle "sky" for underground/indoors maps?

Edited by trollson

Share this post


Link to post
Share on other sites

Well for caves/caverns..perhaps I can actually make a "roof" object and place it in the map. The only problem with that is you'd still see "the blackness beyond" with certain camera angles(think of a dome with the normals on the inside, fit around the whole map).

Right now there is no way to contain your view to the real map part only, so there'll always be that ugly blackness.

 

for house insides...that's another problem as you can see other insides. I could place a big black wall object between all the houses, but that'd make it difficult to then use the map editor because the editor is limited in it's camera angles..so now that i think better on it that's out.

 

I'd say perahps we can kill the objects viewed at a much shorter distance-that'd work for most house insides, but some, like a castle with a long hallway, wouldn't.

 

I think to really make it work you'd have to have it work like they do in most games nowadays..when you go in a house, the camera is contained in that house, so you'd see a roof too.

I do'nt know..what do you guys think?

Share this post


Link to post
Share on other sites

Caves and the underworld could just be a perlin noise texture that is not animated at all. The problem comes in to the maps that have multiple sections on them (like the houses/insides). If each house had quad roofs, then you could look into the room along the direction of the normal, but if the camera was actually inside the room, you would see the ceiling (IIRC).

Share this post


Link to post
Share on other sites

Perlin noise or whatever sounds okay, but a little animation in terms of one sliding over and blended into another for the Underworld would go a long way to making it look good. Caves can be pretty static.

 

In terms of specifying what skies/fiery infernos to use where, I was thinking that something like the music config files could be used. When a map is loaded, sky textures in the sky file for that map are read and applied. That way the sky can fade ominously to dark in certain areas on maps, and we have a solution to the problem of what to do to represent the horizon, whether it be land or sea, when people get to the edge of maps: the horizon is specified by rectangles near the edges of the map.

 

Another issue that needs to be dealt with is the fact that on interior maps other unrelated, or supposedly unseeable, interiors are visible. Roja mentioned this. There needs to be some way to specify what areas to show. Normally this would involve portals and such. I think that perhaps we need a plan to deal with this. But this is a LOD issue.

Edited by emajekral

Share this post


Link to post
Share on other sites
Silly songs with Ezzat

 

And, of course, a look at the latest iteration of the skybox.

heh, funny. it's looking pretty good. though I worried when it stayed black for a while. how close is it to beta testing (as in I can compile it for other people to look at, update now and then, etc, as I like to do) Edited by ttlanhil

Share this post


Link to post
Share on other sites

That's a cool song, and if you're the one singing it you've got a really good voice!

 

Maybe it's silly..but it can be really touching when people make songs about a game I helped create :blink:

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.

×