How feasible is 2D ray tracing?

I’ve finally come back to doing my raytracer(Spent the last few days obsessively playing Ogre Tactics ).
Anyway after fining up the math I ran it and I’m getting something in the order of 10fps.

I’m just simulating shadows which is not even close to being complicated.
When I add other features such as reflections and the like what would performance be like?
When I mean reflections, I mean a ray by ray reflection with the appropriate refraction index calculated in real time.

If I’m simulating real world physics in pure 2D form is it even possible to get usable frame rates?
I’m having doubts about the feasibility of 2D real time ray tracing to simulate lighting, reflections, shadows and a few more things.
Even though it is easy to do, it isn’t easy getting performance into a usable number.

At this time it’s all purely done on the CPU.
Also I would like to add HDR to it.
What you’d get is a platform game with raytracing and realistics looking physics effects.

Suggestions?

Why go for raytracing over rasterization? It’s not really my area of expertise, but as far as I know there are no convincing examples of realtime raytracing yet besides research projects. As an example the guys working on OpenRT mention on their site that they have a game prototype that runs at “interactive” frame rates (read 5-20fps) on a cluster of machines that amount to about a 30Ghz computer. Not exactly stellar performance :slight_smile:

In case you missed it, here’s my attempt at RTRT from last year’s 4k contest… I’ve got > 40 fps, but the scene is really simple ( a plane and some spheres) and the resolution is limited.

Lilian

I’d like to mention I’m not talking about 3D raytracing.
I’m talking about 2D raytracing.

The same thing but without the 3rd dimension.
I’m wondering whether the same argument applies in 2D against raytracing?

I just played your demo, your comment below suggests that that was in 2D, is this true?
It looked as though you were using LWJGL but I could be wrong.

Are you using shaders within your demo?

I can’t say I understand how 2D raytracing would work in practice. If I remember my CG course correctly, the origin of the rays is the position of the observer. So if you’re making a 2D platform game, where is the observer located? Even if all your data is coplanar you would still need to position the observer somewhere outside this plane or you couldn’t actually render anything useful.
For some reason I have a feeling I’m missing something obvious here ;D

http://members.optusnet.com.au/ksaho/show/correct.JPG

This is what I mean by 2D raytracing.
So far it takes .12 seconds to render a single frame.

7.8 seconds for 60 frame.

Green lines in the pic are the normals.
The rays are coming from the sun, hitting the box and then reflecting back at the source.
Please tell me it looks correct. :slight_smile:

It looked wierd at first but my maths is correct.

about my demo : it’s pure 3D raytracing, the ground uses a procedural texture based on an optimized perlin noise.

there’s no opengl in it… everything is computed in the CPU, although I’d also like to try it based on GPU to see how well it could perform…

about 2D RT… I can’t see any practical use in a game( except a ‘radar’ flat view ). but I might be wrong.

Lilian

That can not be correct. The reflected rays needs to be mirrored around the normal, not go back where it came from.

This by any chance look more or less correct?

That doesnt look right either, i would geuess the amount of fesability depends on how much surfaces each ray are relfelcted off, actually it looks a bit like ray casting which is feasible of course.

This is what i think of a ray hiting a surface looks like:

If you’re just calculating the rendered lines, that should take a LOT less time than that, you can heavily optimize your code. This may be all the reassurance you need - what you’re (attempting to…) doing is very fast when you get it sorted out, and you’re fine to use it as a core part of your rendering.

In fact, it’s so fast that it is often used as an optimization to improve rendering speed on complex polygon soup (useful for doing quick PVS calculations). I’m not saying it’s the best way, but plenty of people have used it for this (it’s pretty simple to implement, debug, understand, etc).

However, you might want to seriously answer the question: what is it that you are trying to achieve here?

Yeah, it’s a nice example. To add to this, back when I was an undergrad, I too wrote an FPS that used 3D realtime raytracing, and with no reflections I had at least 30 fps (this was rather a lot of years ago) in complex scenes with lots of objects, some shadowing, etc.

FYI - the game was set in caves / dungeons, keeping the visible set relatively low, and I cheated and used some Doom optimizations - e.g. doing full raytracing on one ray per vertical scanline wherever possible, and interpolating down (cuts out a surpsingily large number of calcs if you can find believable interpolations)

I’m trying to achieve lighting in 2D using ray tracing.
Due to it being infeasible in 3D, I decided I’d do it in 2D.