Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Project: RRE (Raytrace Rendering Engine)  (Read 4075 times)
0 Members and 1 Guest are viewing this topic.
Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Posted 2006-11-15 04:33:40 »

As a critical part of my next year's entry I am attempting to make a real time raytracing engine which will render my scene.

The objectives of the render are:

- achieve 15fps at 800x600 on a reasonably modern PC
- reflection
- refraction
- simple shadows
- textures
- bump mapping
- fog
- able to handle spherical and triangle primitives
- use a bounding volume heirachy



I now have the render at an inital stage able to display the bounding volumes (spheres) which represent objects.
- no secondary rays are cast yet.

Currently with no code optimisations and only proof of concept frustrum subdivision optmisation implemented it is able to render a scene of 41 viewable objects out of a total of 32767 objects onto a 800x600 screen in 0.2 seconds using a Pentium 4 duel core 3000 mhz (thus really only 1500 mhz thanks to java not utilising both cores).

This seems holds promise. My biggest concern is whether i am able to reduce reduce the class size to fit in 4k and allow a game as well!


Below is a screen shot thus far:
Click to Play


The magenta areas represent the bounding spheres of the objects, the yellow gridded areas show the frustrum subdivision.

The darker the magenta the further away the object is from the camera.
Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #1 - Posted 2006-11-15 05:21:15 »

I have implemented an optimisation which tests each corner of a sub divided frustrum to see if all the corners hit the same object. If they do then then all the pixels in that frustum must also hit the object and so we do not need to sub divide further.

This holds true given that all the primitives shapes are concave (which they are).

This optimisation has speed up the render significantly and it is now able to render the same scene in 0.06 seconds!

Click to Play


Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #2 - Posted 2006-11-15 06:15:14 »

Being a 3D in 4K fan myself, this looks fascinating.  I'm looking forward to seeing how it turns out, even if it doesn't squeeze down into 4k.  Many years ago I made a full real-time raytracer for the Acorn Archimedes in hand tuned machine code (no lighting, no texturing, no reflections, very low resolution), using hand crafted fixed point arithmetic crafted to take advantage of the limited parallelism in the ARMs arithmetic logic unit.  It did work, but was very low resolution and suffered from fish-eye lens distortion, due to some algorithm simplifications.

Not much progress on my 3D entry yet.  I'm using a stripped down version of the terrain raycaster from last year, in conjunction with a new object rendering system.  The object renderer is only a theoretical paper concept, and is a bit unusual so is under wraps at the moment.  There's a nasty square root in the algorithm that gets processed on a per pixel basis, thats probably going to need fixed point and a look-up table.  Game size is currently 2K (compressed) with the basic terrain renderer, but without the object renderer and gameplay elements.  I'm under severe time pressure, so probably no further progress until December.

Time flies like a bird. Fruit flies like a banana.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #3 - Posted 2006-11-15 11:29:40 »

I have always had a facination with raytracers. I guess it just makes more sense in my head Smiley I have always wanted to try my hand at a real time ray tracer so this 4k comp should give me impetus and motivation to finish it.

I think i may be a little ambitious with all the objectives to fit in 4k, however i hope to at a minimum have:

-sphere and triangle primitives
-reflection
-at least 15 frames at 640x480

I have to think on how to store 3d models sufficiently compressed so that they can be used in a 4k entry. To this end i am going to try and fit the rendering engine in 3k allowing 1k for gameplay and models. Lets see if i can achieve it Tongue

That Acorn rtrt sounds crazy! I would not have thought i would be possible to achieve decent frame rates on older hardware such as that! A real credit to you for accomplishing that feat! or should i be backing slowly away from the scary person Tongue ?

Yeah, those pseky square roots are trouble. what sort of range does the value being square rooted have? maybe an approximation lookup table would be sufficient?

I am surprised that it seems no one has used view frustrum sub division culling in the manner i am using before. I would have thought that it was a logical progression from normal view frustrum culling.

what i am currenly doing is:

1. initally sub divding the view frustrum into 4x3 sub divisions
2. for each of these sub frustrums see what objects from the parent sub frustrum is potentially visible in the new sub division
3. if there is at least 1 object visible then sub divide the current frustrum into four sub divisions
3a. ray trace each corner of the subdivision to see if each courner hits the same object.
3b. if all corners hit the same object then assume all other pixels in the sub division likewise hit the object
3c. else  repeat 2

To speed up the process, for the inital view frustum i am approximating it as a sphere to cull most objects. Then i approximate the frustrum as a cone to further cull objects and finally i cull the objects using the actual frustrum. Like wise for each subdivision i approximate the sub frustrum as a cone first. It seems to speed things up considerably.

This new object render you speak of does sound intriguging Smiley cant wait to see it practise!
Offline c_lilian

Senior Devvie


Projects: 1


Java games will probably rock someday...


« Reply #4 - Posted 2006-11-15 13:14:26 »

Hey, good luck with your RTRT !

for my 2005 entry  http://vlsolutions.com/free/bubbleracer2005/ I had to drop so many things to fit into 4k that it was a little bit disapointing.

One day we'll gather and start a special 8k RTRT contest Smiley, THAT would be really interesting !

Good luck anyway, and looking forward to see your entry

Lilian Smiley

Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #5 - Posted 2006-11-15 22:06:26 »

Hehe, i do remeber your posts as you progressed with your entry.

Any chance that i can have a peek at your source code so i an gain inspiration and hopefully avoid pit falls?
Offline c_lilian

Senior Devvie


Projects: 1


Java games will probably rock someday...


« Reply #6 - Posted 2006-11-16 07:09:13 »

hehe, you don't really want to have a look at my 4k code (even I don't understand it anymore !)

Lilian Smiley

Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #7 - Posted 2006-11-16 21:29:39 »

lol i understand!
Offline nonnus29

Senior Devvie




Giving Java a second chance after ludumdare fiasco


« Reply #8 - Posted 2006-11-18 20:52:13 »

Being a 3D in 4K fan myself, this looks fascinating.  I'm looking forward to seeing how it turns out, even if it doesn't squeeze down into 4k.  Many years ago I made a full real-time raytracer for the Acorn Archimedes in hand tuned machine code (no lighting, no texturing, no reflections, very low resolution), using hand crafted fixed point arithmetic crafted to take advantage of the limited parallelism in the ARMs arithmetic logic unit.  It did work, but was very low resolution and suffered from fish-eye lens distortion, due to some algorithm simplifications.

Not much progress on my 3D entry yet.  I'm using a stripped down version of the terrain raycaster from last year, in conjunction with a new object rendering system.  The object renderer is only a theoretical paper concept, and is a bit unusual so is under wraps at the moment.  There's a nasty square root in the algorithm that gets processed on a per pixel basis, thats probably going to need fixed point and a look-up table.  Game size is currently 2K (compressed) with the basic terrain renderer, but without the object renderer and gameplay elements.  I'm under severe time pressure, so probably no further progress until December.

For my entry-that-wasn't last year I had a 3d polygon renderer with flat shading that came in at just under 2k.  That other 2k doesn't leave much room for gameplay.  That's one reason why I was so impressed with the 3d shooter Ares last year.  Maybe I'll revisit mine if I have time.  But wow, is it hard.
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #9 - Posted 2006-11-18 23:10:14 »

Nonnus, I'm not too worried about having used 2k so far, since that includes all the overhead of the class, creating the window, player movement etc. However the size of the object renderer (with object definitions) will be critical. I know how big a triangle renderer can get and I'm amazed you got one in 2k.  For that reason, I won't be pushing triangles, but don't want to say more, in case my plan doesn't work out.  Unfortunately haven't got time to work on it this month, but it should surface sometime in December.

Time flies like a bird. Fruit flies like a banana.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline LME

Innocent Bystander





« Reply #10 - Posted 2006-11-19 15:27:37 »

Interesting project, keep us posted on your progress, 32k object is alot! Smiley Im trying to develop an interactive raytracer for this year's competition aswell but I've started in the opposite end from you. Im writing the shader code first and then I'll try to optimize it for speed and size.. kinda backwards I know. The previous raytracer I wrote (Prong in the 2004 version of j4k) had severe performance troubles at the time so my goal this time is to write something a bit faster, a bit larger and a bit more fun!
Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #11 - Posted 2006-11-20 01:47:20 »

It seems this year will be the year of the 3d engines in 4k Tongue

I am sure that there is no "correct" way to make a 4k entry let alone a ray tracer in 4k! It will be interesting to see what happens!

I am not so worried about performance rather than the byte code size the raytracing engine will take. It will be not much use if I only have 300 bytes to make a game with it Sad
Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #12 - Posted 2006-11-20 08:12:42 »

Quote
It will be not much use if I only have 300 bytes to make a game with it

Raytraced Pong! Grin

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #13 - Posted 2006-11-27 05:57:10 »

After spending gads knows how many hours trying to understand why my frustrum division algorithm was only partially working I had a relevation and now have my first hit optimisation algorithm at a state where i now will turn my focus onto secondary rays.

The problem was while  it divided the frustrum correctly until it had a frustrum with contained an object in the scene from then on it always sub divided no matter if the sub divided frustrums contained an object or not!

This meant that there were unnessary subvision and ray intersection checks.

Currently the renderer is able to render the same scene in 0.047 seconds:

Click to Play


I have not implemented any mathematical or coding optimisations at this stage,. I plan to have a working version of the render before I go optmising and byte 'hunting'. I anticipate a further 25% increase in performance after I do optimise.

All in all it is still looking viable Smiley Now the big question is to see how much of a hit the reflected rays and refracted rays will cause.

Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #14 - Posted 2006-11-27 10:49:46 »

Does anyone have any ideas as to how best repsent an "object" which can consist of 1 or more spheres, triangles and hopefully cylinders?

When i say best i mean in the least total bytes. (including the object 'reader' which would add the object to the rendering engine)

I would imagine seperating each different aspect of the model and then storing like aspects 'close' to each other in a stream (perhaps as a Hexadecimal string) would aid the Deflate mechansim and help reduce the model byte size... But would the gain be lost from the extra byte code needed to interpret the stream...

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (67 views)
2014-11-26 15:22:04

toopeicgaming1999 (58 views)
2014-11-26 15:20:36

toopeicgaming1999 (13 views)
2014-11-26 15:20:08

SHC (26 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (30 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (76 views)
2014-11-13 12:34:49

digdugdiggy (53 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!