This topic is now archived and is closed to further replies.

Voxel frame rate problems

This topic is 5838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, I have been working voxels under opengl over the last few days. I can get 7 million voxels on a screen at a time at 70fps, but the strange thing is that if I reboot my machine, load borland builder 5 (and the project) and then run the program, the first time always runs at 20 to 30 fps. After I quit it once, it runs fine again at 70fps and constantly afterwards. I am using WinME for the platform (and have maxmem running). Another question is that when I cycle through the voxel modes, textured voxels seem to drop 5fps if I cycle away from them (I think this is to do with my code though, but I will sift through it and find it hopefully). Last question is about the glVector3fv against glVector3f (pointer to array, vs direct values). When I use glVector3fv instead of glVector3f, the program runs fine (same fps) except for the first couple of seconds (between 2nd second and 5th or 6th second) it slows down by about 10fps. Does anyone know/have had troubles with glVectorXfv functions and this lag effect? If so does anyone have any idea how to stop it? PS - if it helps I am running at full screen at 1024x768 using a gforce 2 and 1g athlon with 512 mb sdram, and as stated above with winme, maxmen and borland builder 5 pro. Thanks in advance. Beer - the love catalyst

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
PS - its a geforce 2 MX Winfast and the machine is not overclocked.

Share this post

Link to post
Share on other sites
You''re a better person than I am.

7 Million, wow... you should be rich.

I gain performance with the *fv, no loss. There''s something wrong with your OpenGl anyway, it wouldn''t surprise me if all those problems were related to the initialisation...

Share this post

Link to post
Share on other sites
probably is. I haven't really done much opengl stuff (in any depth) for a probaby a year or so now (maybe 2, possibly 3).

Well my initialisation is basically standard windows setup. I haven't been using the Builder stuff as I noticed that when I wrote a small http program (was scripting 3d views and stuff) which had OpenGL in a window, it gave out to many exceptions all the time so I said screw it and went back to the old way. The above engine was using the setup from a program I wrote a long time ago. I will see if I can port the voxel stuff to the standard builder setup and see if I get the same probs.

PS - I am not sure if terravox does it (is that your engine?) but I use compressed voxels.

Basically, the slow stuff in the program is that if you have a loop such as
it slows it down like buggery. If I just add the above code in the program and I loose around 10 fps. Compressing the voxels and decomressing on the fly makes it run like a daemon with a pitchfork up his arse (don't suffer the delay from the loops, and the overall effect was around twice the frame rate).

Also, if you render cubes around each of your voxels, don't render non-visable sides. ie; the ones that have some other voxel against it.

Oops - forgot the sig - highly important
Beer - the love catalyst

Edited by - Dredge-Master on December 13, 2001 12:50:05 PM

Share this post

Link to post
Share on other sites
Yeah, terraVox is my engine. It does landscapes only, and that allows a hell of a lot of optimisation... see my tutorial on flipCode. I don''t call it compression, but heightfield mipmapping. Which is LOD for voxels essentially.

7 million, that''s 192x192x192 resolution voxelisation? How many polies is that? (I don''t use them in tV).

Share this post

Link to post
Share on other sites
The only poly''s I set it to use are GL_FLAT quads and textured quads. Alot of the texture stuff was vector and normal stuff I had written a long time ago. Thanks to it the thing has some decent speed. Actually thanks to uni (university) and those darn maths subjects (which btw I failed quite a few times - but less than most people) I was able to write them to be faster than all the stuff on the net.

I am writing my own lighting code for it, as since the polys are too small they can''t use the Open graphics lighting, so that slowed it down.

When using polys they are just a cubes around each voxel location. I also have scaled gl_point voxels that (unless you have a darn small model or are really close) look the same as the gl_flat quads.

After timing it (7 fps counters for the different sections) all the overhead is in the code, not the rendering of the quads which proves that the GeForce II was a good investment.

Oh yeah, I recompressed the voxel image in another layer and gained 10fps on textured voxels.

I got that glitch with the glXXXXfV functions sorted out btw, so it doesn''t lag at the start.

The reboot problem is still there, but I can live with that at the moment.

Plans for it now
- currently working on software lighting
It only works on lights along one axis though, so I will probably have to spend a few more hours on it. Afterwards glass and shadows is to follow - simple ray tracing stuff.
- after that works I am going to wack in a detailed "utah teapot"
- then wack in a gui so you can move the lights around.

Hard part is those bloody lights. The way I wrote it has the polar co-ordinates (used for the normals) in weird orientations so I have to go through and change it all.

I will have a look at your article now Alex. I appear to have waffled on for long enough.


PS - I stuck in more ram (640mb now). Tthis thing is taking around 160mb of memory or so at the moment. Small sacrifice for the speed atleast.

Beer - the love catalyst
Nice artical.

Did you know that Ken Silverman''s KVX engine is 6DOF? I worked on it a few years ago for a game and some wrote utils for it. Bloody awesome little thing. 100fps on a 120x120x80 voxel at the highest LOD in 1024x768 on a P100 with a 2D card.

If it was written for win32, I would have never started this little voxel project. Oh well, the days of MSDOS are behind me.

Beer - the love catalyst
If you only need directional lights that point from 45 degree angles (N, NE, E, SE, S, SW, W, NW), which I know is a very limited case, then the fast and easy way to do it is to simply use slope lighting like this:

lightvalue = getheight(x, y) - getheight(x - 1, y) + 0.5f;


Edited by - TerranFury on December 16, 2001 2:11:14 PM

Share this post

Link to post
Share on other sites
I guess that the reboot problem comes from the MSWindows memory management or memory caching algorithms, voxels are known to be memory eating, the first time you run your program it starts to allocate and load voxel data into memory, but in the second and further executions the memory allocation differs, i don''t know what exactly happens but i''m almost sure about this. Another issue maybe the borland''s memory management (not the windows memory management) borlandmm.dll does this for you, try executing your program from outside the BCB environment (run the exe file directly) this may help.

And i love voxels, i also use BCB ) i have an old voxel landscape engine, you can see a little screen shot of it in :

--Ali Seyedof

Share this post

Link to post
Share on other sites
Firstly, I would like to say FUBAR due to the optus international access being down (Optus Cable in Australia).
The above images shows how I got to this page.

Well about the lighting, thank you for the code snippets.
Fortuneatly I got it figured out. My problem with the lights originally was that I was tacking them to the viewing rotation. Since I did that I had to work my way back from it and get it to load all the lights.
In the end I deleted it, then used the Dot product in Component form, and whipped up a few functions to do it all for me.
It worked great first time round. Then I just tweaked it and made some lookup tables to make it faster. It happily processes 6 lights at the moment, but when I had 60 lights running on the above sphere it dropped down to 6 fps (coloured lights).

About the memory thing, it lags even without the Borland IDE. I will try it on this machine some time and see if it still has the same error. If so I will give win2k or winxp a try and see if it is just windows or my code. Easier than reading my own code.

Well I will download the image you gave me the address of then ftp it back so I can view it.

Oh yeah, incase anyone wawnted to know why I was working on a voxel system, it is so I can make a 3D game along the lines of Scorched Earth/Worms where you can dig out holes in the ground (like in QBasic's Banan/Gorilla where you could disable the gravity effect on the ground).
The minimum frame rate I am trying to achieve is only around 15 to 20 so the game is playable at high res, and so the mouse cursor doesn't lag.

Until Optus fixes up this bug I probably won't be here much, so seeya al later.

Beer - the love catalyst

Edited by - Dredge-Master on December 20, 2001 7:47:43 PM
Nice screenshot there Seyedof (off your site for the games section).

I tweaked the engine some more, rewrote the sin, cos, acos and tan functions (still changing them to speed up the float to int conversions) and then changed the light processing. Sped it up a shirt load. Also tweaked bits here and there and added in some culling to the voxels (not just the surfaces) and the frame rate is now at 40fps for a textured sphere with 6 lights

also added in a gui so you can set light colours, diffuse reflection, diffuse atmosphere reflection and the colour of the voxel object (if I add in any editing features, I will put in a paint feature so you can use different colours on the voxel model). The gui also has light controls and voxel display type controls. I will try to get the fps up higher, then upload some screenies and a small sample prog to test the gui on my site somewhere.

Beer - the love catalyst
the best voxel stuff ive ever seen are Delta Force2 engine which does Voxel Tiles and Voxel Texturing, the other is Ken Silverman''s voxel engine which renders complex curved objects.
Im working on a voxel/polygon engine for a military simulation project, it includes a nice and powerful terrain generation and editing tool to add rivers, lakes, roads and other stuff to a heightfield landscape
waiting to see a demo of your engine

Share this post

Link to post
Share on other sites
Yup, I loved Delta Force 2''s engine. (best thing though was shooting a guy in the arse or groin with the sniper rifle and watch him either 1 - grab his arse and jump around, or 2 - grab his groin and buckle forward)

Well anyway, I rigged up a small sample program of my little engine so you can see the four different modes and the real time lighting.

Link is on the bottom of the page. It is 603kb.

All features are mouse driven with the mouse movement, left button, right button and scroll wheel (sorry if you don''t have one - it controls the zooming and the "closeness" of the lights only though - I will add in keys for it if I upload another one)
The only functions to be mapped to the keyboard are as follows:
Escape can be used to exit, and F1 to toggle the edit panel
insert to add lights,delete to delete them. f5 to f8 to switch between the four modes. you can also use 1 to 9 to select a light from 1 to 9

The model is a solid 64x64x64 sphere. 6 lights by default.

Maximum lights are set at 30 (can''t fit any more on the edit display without changing the size of it). New lights default to .5r .5g .5b and normal atmospheric reflection, at location 1,1,1. To add one of these lights, click add (cross) or hit insert

To delete a light, click the minus sign (the minus sign) or hit delete. Then click on the question mark next to the light (was a switch, changes to a question mark when deleting). If you wish to cancel the delete, hit the minus sign (now a cross) or hit delete again.

To select a light, hit 1 to 9 or just click on the colour of it on the right.
To turn a light on and off, click the switch next to the light.
To unselect a light, just click on it again (or press its number). When no lights are selected, the model is selected.

To select a voxel drawing mode, click on one of the four images of the model or hit f5 to f8.

To change the colour or the atmospheric reflection(if a light is selected) or reflective diffusion (no lightis seclected) drag/click on the four bars at the top. red green blue are the colours, white is the atmospheric reflection and the reflective diffuision one.

To minimise/maximise the colour editor, click on the icon second from the right on the bottom (line or box) or hit F1. To exit, hit the bottom right icon ( a cross) or hit escape.

if no lights are selected hold right button down and move the mouse or the scroll wheel to rotate/move the display

if a light is selected and you have the right button down, it will move the light around when you move the mouse or the scroll wheel.

Have fun.

PS - I think that wall image was from the demo of a Rainbow Six game or possible counter strike or the new TFC maps. I forgot where.

Beer - the love catalyst