Jump to content
Eternal Lands Official Forums
Bharain

Camera freedom, zoom and the sky

Recommended Posts

I've been playing a different RPG a bit lately and on returning to EL the camera feels very restricted. It only has 15 degrees of up/down movement, with perspective mode you can get to see a bit of the sky but the FPS dies off horribly. So i was thinking, could we give the camera some more freedom without paying for it in FPS ?

 

I had a couple of ideas about how it could be done:

 

1) Simply reduce the far plane so anything distant gets chopped off, looks like this.

 

As you can see my FPS still struggles like this (normally doesnt go below it's 60 cap) also you get that dreadful drop off the edge of the world.

 

2) Same as 1) but fog just infront of the far plane to cover up the drop away

 

3) Some sniffing around 3d_objects.c turned up the near_3d_object functions which got me thinking, would it be possible to use these functions to only draw the objects within a certain distance of the player (configurable by the player for FPS reasons). If so we could have a circle of detail around the player, a larger area with just plain undetailed grass/water and then a drop off into fog at the horizon.

 

Another problem besides FPS is that i can still only click and walk within a small area, anyone know if this could be extended? It must be possible if you can click the other side of the map and walk there.

 

Even with the rough far plane hack i prefer the sense of space and being able to see the sky :P

 

Anyone think this is possible or a good idea? Please comment even if you don't :)

Share this post


Link to post
Share on other sites

Here's how it looks only drawing near objects:

 

drawregion8le.jpg

 

Wonder if it's possible to do 3 regions:

 

1) close, full detail

2) middle, low detail objects

3) far, no objects

Share this post


Link to post
Share on other sites

I think what would need to be done is to have various levels of detail for the static 3d objects. So if you have a super computer, you can see more 3d objects(there would be a setting that you can change the levels).

 

For the dynamic objects-players, monsters, this level would have to be the same for everyone of course. They would pop in/out of veiw when they reach a certain distance, although it'd be nice if they can sort "fade into the fog"..but i dont know how all that stuff works, just giving my opinion here.

 

There would also need to be a fog, just like in other games, so you don't get what you see in your above screenshot with the ground plane going on endlessly..it looks ugly. The fog would blend the sky and the ground.

Share this post


Link to post
Share on other sites

Here we are with some fog:

 

fog1eb.jpg

 

All i did here was increase the min_fog variable in weather.c so if you turn off render fog it vanishes. Once we decide how it should look i can do it properly :confused:

 

For drawing objects i'm only changing 3d_objects.c so it shouldn't effect monsters etc as they're handled by actors.c.

Share this post


Link to post
Share on other sites

Can you make a real dynamic sky for the game? I can make the images needed.

The fog may have to be changed a little..but we'd need tos ee what a sky would look like first I think.

Share this post


Link to post
Share on other sites

Can you make a real dynamic sky for the game? I can make the images needed.

The fog may have to be changed a little..but we'd need tos ee what a sky would look like first I think.

 

I'm working up to that, getting to know my way around the source. If i'm not mistaken clouds already exist they would just need drawing and different effects applying depending on the light. I'll look into it a bit more later tonight.

Share this post


Link to post
Share on other sites

The clouds exist as a texture for the water surface. It is a very very basic texture..wouldn't work for the sky if we want to make it look good.

Share this post


Link to post
Share on other sites

Another problem besides FPS is that i can still only click and walk within a small area, anyone know if this could be extended? It must be possible if you can click the other side of the map and walk there.

 

Yes, it can be extended by using pf_find_path() in place of MOVE_TO.

Edited by Bongo

Share this post


Link to post
Share on other sites

Sorry about this, shortly after starting on this i got a job and between playing and working i haven't found time to work on programming for EL. If anyone else decides to work on a sky here are some links i found useful:

 

http://www.gamedev.net/reference/articles/article2085.asp - Generating Clouds

http://www.spheregames.com/index.php?p=tem...pages/tutorials - PDF on Sky Domes

Share this post


Link to post
Share on other sites
I never remember ANY pictures of a sky in EL. The only person who started to look into it was Bahrain, who just posted that he can't work on it now.
ahh yes. there were a few screenies posted of it, I'm pretty sure. oh well, if the code is available it may save a fair bit of time

 

I may have posted this in IRC but not on the forums:

 

cloudspt8.th.jpg

 

As you can see it has some blending issues :P

 

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.

Share this post


Link to post
Share on other sites

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...

Edited by trollson

Share this post


Link to post
Share on other sites

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.

 

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.

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

How many suns and moons does Draia have anyway? I forget. Trollson is correct that the positions can be very deterministic and do not need much serverside other than the clock. I think that the day and month would be handy for moons as we could use them for celestrial events, such as an eclipse formenting one of Mortos' invasions.

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

×