Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Tue Mar 19, 2024 5:34 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Graphics front end
PostPosted: Wed Dec 19, 2007 2:41 am 
Offline

Joined: Tue Dec 18, 2007 5:37 pm
Posts: 4
Hi there,
Please correct me if I get things wrong, I've not extensively studied the raydium source, or even compiled it.

The physics engine seems great. The rendering engine .. works. But looking at the source there looks like a lot of things you could improve upon. Btw .. i write opengl stuff for a living :p

Firstly .. you need to define a standard polygon winding to use in your engine. Either clockwise or anticlock wise. You don't want to render the backface of poygons. What the point ? :p

Next .. a culling system. Opengl will cull everything outside the view frustum planes, but you will still have to send everything to render every frame, which is wasted clock cycles ..

If you don't have any culling system and you send the entire world to be rendered every frame .. You might as well upload the entire world to the graphics card, either with good old display lists .. or maybe use http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt. This will work but won't scale if the world gets more complicated.

Next .. immediate mode. (This means using glbegin glend etc) Immediate mode is the worst way you can pass data to opengl, due to the high cost associated with the function call overhead. It's fine for a thousand or 2 vertices, but once you start pushing more it'll start to become a bottle neck. Ie immediate mode scales badly. You wanna use indexed arrays or just simply vertex arrays. The particle rendering looks like it could easily be changed to use vertex arrays. Just put all the data in a giant array and send it off to opengl. One call instead of .. potentially thousands.

There's no point in adding like, reflections or shadows if the engine is so unoptimised. It will just scale really badly.

The lighting. Opengl per vertex lighting is stupidly fast on modern hardware. You really want to pass 1 normal per vertex and not 1 per face. That way you can interpolate the normals between adjacent blocks. That will stop the flat shaded look and give a more natural feel to the lighting.

I hope these comments are useful, thanks for a great game :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 19, 2007 11:49 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Thanks for the comments.

A few ones are also in our TODO list, in fact we have a "full opengl core rewrite" :)

About the lighting. If i understood right you mean we should trash the vertex lighting and use instead the perpixel ligthining? It's really so fast? I'm not sure about that.

Also i 'd like Raydium would support OpenGL3, but we'll see what have to say Xfennec (the father of the beast).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 19, 2007 3:06 pm 
Offline

Joined: Tue Dec 18, 2007 5:37 pm
Posts: 4
no i didn't say trash vertex lighting
and yes it really is that fast. A lot of older hardware is optimised to do it really fast.

The problem is just the normals. If you give one normal per face, each vertex on that face will have the same normal. If you give different normals for each vertex the normals will be interpolated (smoothed) across the surface, making everything look less flat and blocky. With per pixel lighting, everything would still look flat and blocky if you used the same normals. In some cases you might not want to interpolated the normals though.

Per pixel lighting throws up a lot of problems, like what to do with overlapping lights. Lower end cards dont support loops in shaders so what do you do with more than x amount of lights ? The solution often was to blend the result in the colour buffer which doesn't do nice things to performance :p


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 30, 2007 9:31 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Hi,

You're missing a few things ;) Raydium does not use immediate mode, since it use compiled display lists. This is not, for sure, the fastest way to do things, but it's currently the best one for our needs (before the big-core-rewrite-things that may happen one day :) )

About culling, I've decided to remove it (there's still a few lines of code there and there) because it gives some rendering cost back to the CPU (and this not the way to follow, as modern graphic cards shows) and collides with display lists, vertex arrays, ... The current rendering code is here because it was the fastest of all our experimentations.

To make a long story short, currently Raydium scales quiet well ! And WITH reflections, shaders and shadows :) You can have a look to screenshots and video of Raydium website, if you want.

The main problem currently with ManiaDrive are 3D assets. They were made by us, not real graphist people :) That's probably why you've created this post and why you seems to think we only deal with per-face lighting (in facts, Raydium deals with with smooth groups since ages)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 31, 2007 4:26 pm 
Offline

Joined: Tue Dec 18, 2007 5:37 pm
Posts: 4
Quote:
Raydium does not use immediate mode, since it use compiled display lists.


the code for particles very much looks like immediate mode ? I'm not seeing any display lists there.

Code:
for(i=0;i<RAYDIUM_MAX_PARTICLES;i++)
    if(raydium_particle_particles[i])
   raydium_particle_draw(raydium_particle_particles[i],ux,uy,uz,rx,ry,rz);


seems to call

Code:
void raydium_particle_draw(raydium_particle_Particle *p,GLfloat ux, GLfloat uy, GLfloat uz, GLfloat rx, GLfloat ry, GLfloat rz)

..

  glBegin(GL_QUADS); // berk... but i'll switch to triangles one day ;)
  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(p->position[0] + (-rx - ux),
        p->position[1] + (-ry - uy),
        p->position[2] + (-rz - uz));
  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(p->position[0] + (rx - ux),
        p->position[1] + (ry - uy),
        p->position[2] + (rz - uz));
  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(p->position[0] + (rx + ux),
        p->position[1] + (ry + uy),
        p->position[2] + (rz + uz));
  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(p->position[0] + (ux - rx),
        p->position[1] + (uy - ry),
        p->position[2] + (uz - rz));
  glEnd();


you could speed that up a lot if you just packed the data into an array
and used vertex arrays

I don't see any glEnable(GL_CULL_FACE) calls. The default value is false for GL_CULL_FACE so you must be rendering both sides of surfaces, which will affect the fill rate, and generally slow things down.

I very much like the idea of block based system you have. I'd probably make a display list out of each re-usable block. So if you had a 1000 blocks you'd have 1000 calls to draw display lists, which is perfectly acceptable. But I would also sort the blocks by type, or more importantly by texture ID. So that you don't have to switch textures for each block. You'll get a good speed up doing this.

Maybe some sort of culling system would be more important for the physics engine ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 31, 2007 4:45 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Quote:
the code for particles very much looks like immediate mode ? I'm not seeing any display lists there.

Exact, as for a few other things like OSD. But 95% of rendering is done using compiled display lists (see object.c).

Quote:
The default value is false for GL_CULL_FACE so you must be rendering both sides of surfaces, which will affect the fill rate, and generally slow things down.

Test it by yourself, you'll see that the gain is very low :) (since it's only a matter of fillrate, not polycount)
It was a choice made at the very beginning of Raydium, and now, a lot of 3D models uses double-sided triangles, saving quiet a few triangles per model.

Quote:
I very much like the idea of block based system you have. I'd probably make a display list out of each re-usable block. So if you had a 1000 blocks you'd have 1000 calls to draw display lists, which is perfectly acceptable. But I would also sort the blocks by type, or more importantly by texture ID. So that you don't have to switch textures for each block. You'll get a good speed up doing this.


Not sure what're talking about, but ManiaDoes does compile all track assets in one 3D model (see mni_generate() in mania.h) so we can use our regular "sorted texture" renderer, reducing texture context switches.

Quote:
Maybe some sort of culling system would be more important for the physics engine ?

Done, thanks to OPCODE, but physics culling have nothing to do with rendering culling, for sure !

I have a question ... do you think that Raydium is so slow for asking so much questions about performance ? ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 31, 2007 4:57 pm 
Offline

Joined: Tue Dec 18, 2007 5:37 pm
Posts: 4
well speed is not really an issue for me
i have a pretty fast pc 3gig core 2 duo quadro gfx card etc ..

but well maybe this picture will give a clue as to what i do ..
Image

in stereo mode it seems to be able to slow it down to 40 ish fps which is quite some achievement on my pc :) So yeah, I think theres definitely room for improvement. I just like tinkering with 3d engines. Stereo mode also gives clues as to how well the engine scales.

I hope to give constructive critism, rather than nagging complaints. That's all. I love this game, it's awesome. Especially the physics.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 31, 2007 5:16 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
There should be a problem somewhere (video driver ? VBL ?) since we are able to achieve something like 60+ FPS on a GeForce 2 GTS with a Athlon 1 Ghz ... definitely not a super-fast computer, isn't it ?

Raydium can be quiet slow in some areas, for sure, but the way ManiaDrive use it is very -very- straightforward and soft. For example, the game works even on open-source driver for radeon cards and even some intel ones, even if we were only planning proprietary drivers at the beginning.

Anyway, patches are welcome ;)

... and happy new year !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group