Intel sponsors gamedev.net search:   
Journal of YsaneyaBy Ysaneya      
Main project:

Infinity, a space-based MMOG

Forums

Tuesday, August 22, 2006
First of all, the answer from the previous journal: the code that generated this strange, mathematical looking image is the following:

for (TUInt k = 0; k < 128; k++)
{
  for (TUInt j = 0; j < 128; j++)
  {
    for (TUInt i = 0; i <128>)
    {
      SVec3D pos((TFloat)i / 127.0f, (TFloat)j / 127.0f,  (TFloat)k / 127.0f);
      pos = pos * 2.0f - 1.0f;
      m_sprites[1]->addSprite(pos * 20.0f, SColor(1, 1, 1, 0.25f));
    }
  }
}


As you see, it simply creates a 128 * 128 * 128 voxel grid and generates one particle / point sprite for each cell. Nothing more. I'm guessing the strange looking aspect is coming from the particle texture ( which is smoke like ).

Going back to the "serious" stuff: i've been playing with various ways to light the nebulae. Before, each particle of the nebulae had its own color. That would make what is called "emission nebulae", ie. nebulae that emit lighting due to ionization of their particles when receiving light. What i've implemented now is "reflective nebulae", ie. a nebula that reflects color of the nearest stars, so it takes into account the position, distance and color to each star.

I've also added negative blending in order to simulate black dust / bok globules. The drawback is that, as there is no sorting, it can look a bit weird if you move quickly in 3D ( as in the coming video ), but in a sky box it won't be noticeable.

A very short video ( a few seconds long only ) is available here:

http://www.fl-tw.com/Infinity/Media/Videos/Infinity_nebula.avi

The nebulae are now considered close to being "complete". I still have some things to fix and redesign some code a bit, but the graphical aspect won't be improved much.

And, of course, mandatory screenies:








Comments: 16 - Leave a Comment

Link



Saturday, August 19, 2006
Ah, i'm reading your mind. You asked, "part II" ? How many parts will there be this time ? Answer: hopefully, not a lot. I certainly still have more work to do on nebulaes, but i can't see it take more than a week or two ( and anyway, i do not want to spend too much time on nebulaes, there's other things to do too ! ).

So, what have i been doing since the last update ?

Main thing: experimentation. Testing new colors, new algorithms, new variations of existing algorithms, to get a good feeling of what's possible or not.

Technically, i switched from rendering particles to rendering point sprites. Took a day or so to code in ( especially as i had to keep the interface clean to be generic enough for a future DirectX implementation, if needed ). But i'm very happy with the results, especially the memory saving. Think about it: all my clouds are one million points. With particles ( orientated towards the camera in a vertex shader ), it required 32 bytes per vertex, 4 vertices per particle, and 6 indices per particle. That's 1,000,000 * 32 * 4 = 128 MB for the vertex buffers and 1,000,000 * 6 * 4 = 24 MB for the index buffers, so a total of 152 MB of video memory to render my nebulaes.

Now, with point sprites, i only need 1,000,000 * 16 = 16 MB for the vertex buffer, and no index buffer. 16 to 152 is a saving of 9.5 times less video memory ! ( and of course, that's 9.5 times less bandwidth for filling this data by the CPU ). The problem with point sprites is that i had to switch to a rendering that has a constant max point size ( while before, points of the clouds could be of variable sizes if needed ) and that i can only use one texture.

Fortunately, i found a good trade-off: i render the "large features" ( variable point sizes ) with normal billboarding ( where i can control the size and the texture coordinates in a vertex shader ), and the "small features" ( constant point sizes, around 95% of the cloud ) with point sprites. So there's no loss of quality at all. Performance also improved a lot, and i'm now getting from 15 to 60 fps depending on where the camera is located in the nebulae ( don't forget it's fully volumetric ! ).

I optimized the points generation loop by pre-allocating a memory buffer and removing some temp variables, and also optimized the cos/sin calls as David mentionned in my previous journal entry. The net gain is around x3.4 faster than before.

I've added some code to deform the cloud point with some Perlin noise, to give a "turbulence" effect so that "straight lines" generated by strange attractors appear a bit more natural. Of course, as everything in the algorithm, the amount / type of distortion can be randomly generated to have more variety.

On my "todo" list, i still have to:
- test a multi-pass color accumulation algorithm, to avoid the loss of color precision at very low transparencies
- use negative blending for some features like bok globules. Why negative blending ? Because i don't want to have to sort 1 million particles due to alpha blending :)
- experiment 3D IFS ( another equation for generating the cloud points )
- add "main stars" to the nebulae and light it based on the color and distance between each point and these stars.
- i've also been considering rendering particles with normal mapping, but i'll probably drop that since i believe it'll look "good enough" without it :)

The following screenshot is a cloud point ( yes, it is made of one million points ! ). I thought the result was looking very mathematical, and the code is dead simple. Bonus points for anybody who can guess how it was generated :)



The next two images are a nebulae deformed with Perlin noise and rendered from 2 different viewpoints:






Comments: 10 - Leave a Comment

Link



Sunday, August 13, 2006
In the past days i've been working on the strange attractors in order to get nice looking nebulaes. First, let me say that, like any procedural algorithm, it's easy as hell to code the basics, but hard as hell to find the good parameters so that "it looks good". So although in "amounts of code" i haven't done much, i've been very busy testing.

It's still far from perfect, but it's improving. Instead of rendering points, i'm now generating true particles ( billboards, always facing the camera ). About a million of them, to be exact. So, as you can imagine, the framerate isn't very high, but i don't care ( yet ), because in the future the nebulae will be rendered to a sky box instead of being rendered every frame. As long as it looks good and takes less than one second to generate, i'm happy.

Yesterday i added a "glow" effect which is done by taking some particles randomly, expanding them and lowering their alpha value. I then tuned the parameters so that it looked good in my test attractor, and it did. The problem was that as soon as i switched to another attractor, because the distribution of points was different ( more dense, less dense ), the overall "brightness" of the glow effect changed a lot. Using the same parameters, in a second test nebulae, instead of having a nice subtle glow effect, i basically had a white mess due to oversaturation of the additively-blended particles.

Today, i implemented a grid and split particles into this grid. I then discarded all the particles in a cell of that grid except the first one, giving a more or less uniform distribution of particles. Thanks to that, the set of parameters i then choose ( particles size, particles alpha ) is coherent, whatever the attractor is.

I've experimented the "unravel" equation ( kindly given by the chaoscope author ), and he warned me that it was next to impossible to get "nebulae" shapes. To be more specific, you can get nebulae shapes but only in specific 2D views; the attractor, seen from another angle, looks crap, or simply in a plane. I'm going to stick to the "pickover" equation. The generation of the cloud point isn't a bottleneck anyway, so i don't mind the many sin/cos instructions in it.

The main problem that remains at the moment is to lessen the "grainy" effect. If you look carefully at the screenshots, you'll notice that the whole cloud seems to be made of circular blobs. Increasing the size of the particles only leads to over saturation of the colors, and you get a white mess, so it's not a possible solution. I've been thinking of rendering it to a floating point texture and then use a tone mapping operator to avoid the white mess, but the problem is, ATI cards such as the X800 do not support additive blending with floating point textures, so i'm out of luck.

Another solution is to increase the number of points in the cloud, but it takes more time, and since the particles are statically stored in a vertex buffer in video memory ( VBO ), their size is limited. I'm probably already using around 200 MB of video memory just for my particles right now. I should maybe render them dynamically instead of statically, but it'll slow down the rendering even more..

Anyway, here are a new set of screenshots, they're all coming from the same nebulae, seen from various angles:







Comments: 10 - Leave a Comment

Link



Monday, August 7, 2006
ShipBuilder linked a few days ago to a strange attractor program called chaoscope. I knew the existence of strange attractors before, but only as weird mathematical objects and never realized there could be a practical interest for them. Well, i was wrong. When i saw the images created with chaoscope, i realized many of them were looking like volumetric nebulaes, a topic that i already investigated, if you remember my journal updates, maybe a year ago.

Anyway, i quickly started to google for informations about the "maths" behind strange attractors, and it's surprizingly simple; technically, it's just a function that generates a cloud point, each point beind a function of the previous point and of a parameter set. The "hard" part is to determine the parameters that will generate strange attractors automatically, or in our case, nice looking nebulaes ( and i've yet to do that, even though i have some ideas ).

Here's the result of a few hours of playing around:



Of course, rendered in real time ( and still a bit grainy ).


Comments: 5 - Leave a Comment

Link


All times are ET (US)

 
S
M
T
W
T
F
S
1
2
3
4
5
6
8
9
10
11
12
14
15
16
17
18
20
21
23
24
25
26
27
28
29
30
31

OPTIONS
Track this Journal

 RSS 

ARCHIVES
October, 2009
August, 2009
July, 2009
May, 2009
April, 2009
March, 2009
February, 2009
January, 2009
November, 2008
October, 2008
July, 2008
June, 2008
May, 2008
April, 2008
March, 2008
January, 2008
December, 2007
November, 2007
October, 2007
September, 2007
August, 2007
July, 2007
June, 2007
May, 2007
April, 2007
March, 2007
February, 2007
January, 2007
December, 2006
November, 2006
October, 2006
September, 2006
August, 2006
July, 2006
June, 2006
May, 2006
April, 2006
March, 2006
February, 2006
January, 2006
December, 2005
November, 2005
October, 2005
September, 2005
August, 2005
July, 2005
June, 2005
May, 2005
April, 2005
March, 2005
February, 2005
January, 2005
December, 2004
October, 2004
September, 2004
August, 2004