🔒 Locked
3D API Challenge!!!!
Advertisement
Original Post
Me (OpenGL newbie) tried to display 128*128*128 cubes in OpenGL and it went so slow that it brought me to the idea to make a challenge.
I made a raytracer that can display 128*128*128 = 2097152 textured cubes, or in other words this are 25165824 textured triangles for a 3D API. It can display these in real time (dunno how fast exactly, but it's more than 20 FPS) on an Athlon XP 1700+, at a resolution of 160*120 pixels.
Download the raytracer here: CubeChallenge.zip
Then I did something with 128*128*128 cubes in OpenGL (as OpenGL newbie so unoptimized) and not only it took a huge time to load, but also it was less than 1 frame per second on the same computer, even if I resized the window to something smaller than 160*120 pixels.
SO here is my challenge: beat the raytracer with a 3D API! (probably an easy task for real programmers but still..)
Your program must pass the following demands:
*) It must be made with OpenGL or Direct3D and of course use it's 3D functions.
*) There must be a scene of at least 128*128*128 cubes.
*) All cubes that are in camera view and not blocked by another cube must be visible.
*) The cubes must have a 256*256 RGB texture on each side (doesn't have to be smoothed... because my raytracer also doesn't smooth them).
*) There must be 3 different textures: for the X, Y and Z sides of the cubes.
*) The scene must be somewhat the same as the raytracer. That means all cubes together form a big cube and if a cube has a side of 1, there also must be an open space of 1 between two cubes.
*) It must run faster than my raytracer on a computer that is more than one gigahertz, in a resolution of 160*120 pixels.
*) It must run in a window, in M$ Windows.
*) The camera must have 6DOF and be able to move through the whole scene by user control. Note: 6DOF means also that the camera can look backwards after you looked completely up (as in the raytracer).
*) It must have collision detection, I simply mean the camera must be blocked by the cubes.
*) I must be able to run the program on my computer = WinXP box, 512MB, GF3, AthlonXP1700+.
REMARKS:
I. In the raytracer a random 10% of the cubes are white instead of textured... for 2 reasons:
1) Nothing but the textured cubes looked boring.
2) That way you can check that the world really has 128*128*128 cubes and there are no cheating tricks.
Also note that all the white cubes have a different color: in the X direction of the scene they become more redish, Y direction greenish and in the Z direction blueish. But you don't have to do that in the challenge if you don't want to.
II. In the raytracer you can place additional cubes with the b key and remove them with the n key incase you got yourself stuck.
III. In the raytracer use arrows & mouse to move, + and - to change your speed and escape to quit. Oh and with the numpad 4 and 6 keys you can roll the camera, and with the 5 key reset it's direction.
IV. The raytracer may have a long loading time and... more important... it may crash if you close it: check your task manager if it was really closed and end process if it wasn't! Sorry I dunno why it's doing that.
V. The raytracer eats 70MB of RAM so beware. Also don't try to run the raytracer on something that's less than a GHz, it'll be slow on.
VI. I just made this to see how much the cube thing I made in OpenGL will be optimizable.
VII. I could've done 256*256*256 cubes, but that used to much memory.
GOOD LUCK.
[edited by - Lode on July 28, 2002 6:09:42 PM]
*shrugs*
Raytracers indeed beat "normal" engines when it comes down to high-poly sceneries.
This because a raytracers will always fire of a fixed amount of rays. Adding more blocks is fun off course, but if they don''t intersect with a ray, the engine won''t really slow down.
And a normal ray engine doesn''t care if two rays hit the same cube, or another cube.
An OpenGL or Direct3D engine, on the other hand, must loop through almost *every* cube in the world to figure out what is were, is it in view, is it obscured, etc. etc.
One minor trick that might help OGL or D3D: A reaaaaaaaaaally large scene, where you can only see N blocks at a time, and at fixed distances
Raytracers indeed beat "normal" engines when it comes down to high-poly sceneries.
This because a raytracers will always fire of a fixed amount of rays. Adding more blocks is fun off course, but if they don''t intersect with a ray, the engine won''t really slow down.
And a normal ray engine doesn''t care if two rays hit the same cube, or another cube.
An OpenGL or Direct3D engine, on the other hand, must loop through almost *every* cube in the world to figure out what is were, is it in view, is it obscured, etc. etc.
One minor trick that might help OGL or D3D: A reaaaaaaaaaally large scene, where you can only see N blocks at a time, and at fixed distances
Excuse me ??
You want to render 25 mio faces per frame at 20 FPS on a GF3 ?! Good luck... (and if it works, make sure to send me the schematics of the revolutionary 3D chip you designed for it. I will forward it to nVidia... *evil grin with regards to my bank account*
)
Oh and FYI: you can display at most 19200 faces, cubes, teapots, spaceships, 3D refrigerators or whatever else in a 160*120 window: simply because that's the maximum number of pixels available...
[edited by - Yann L on July 28, 2002 7:02:03 PM]
You want to render 25 mio faces per frame at 20 FPS on a GF3 ?! Good luck... (and if it works, make sure to send me the schematics of the revolutionary 3D chip you designed for it. I will forward it to nVidia... *evil grin with regards to my bank account*
Oh and FYI: you can display at most 19200 faces, cubes, teapots, spaceships, 3D refrigerators or whatever else in a 160*120 window: simply because that's the maximum number of pixels available...
[edited by - Yann L on July 28, 2002 7:02:03 PM]
*shrugs*
Step 1: Get object size
Step 2: Get object distance to camera
Step 3: Quickly calculate if size < 1 pixel (pretty quick to do)
Step 4:
-If yes: ignore
-If no: render?
EDIT:
Huuuyaaaa ^_^ Object size is pretty linear compare to distance-to-camera, so just take a save value that you can directly compare against, ie: if (size * value1 * distance < value2) ignore ^_^
[edited by - PouyaCat on July 28, 2002 7:18:18 PM]
[edited by - PouyaCat on July 28, 2002 7:18:36 PM]
Step 1: Get object size
Step 2: Get object distance to camera
Step 3: Quickly calculate if size < 1 pixel (pretty quick to do)
Step 4:
-If yes: ignore
-If no: render?
EDIT:
Huuuyaaaa ^_^ Object size is pretty linear compare to distance-to-camera, so just take a save value that you can directly compare against, ie: if (size * value1 * distance < value2) ignore ^_^
[edited by - PouyaCat on July 28, 2002 7:18:18 PM]
[edited by - PouyaCat on July 28, 2002 7:18:36 PM]
quote:
Hmm but if it's smaller than a pixel it still has to be rendered Otherwise the computer wouldn't know it's smaller than a pixel
Correct. And this is what a) makes it impossible to do it vector based on todays hardware, and b) makes it possible using a raycaster.
Simply because, as PouyaCatTM mentioned, a raycaster does not calculate the cubes that are smaller than a single pixel. If you shoot 19200 rays, it will render at most 19200 (pixel sized) cubes, not one more. If you really want 2 mio 'cubes' on the screen, you'd need minimum 2 mio. rays: try your raycaster on a 1600x1200 window, that would be approx. the right size...
[Edit]
Wow, a cat than can code raycasters... I wish my (pretty dumb) cat would help me code my radiosity engine, now that would be cool...
[edited by - Yann L on July 28, 2002 7:22:56 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement