• Welcome to Dark Bit Factory & Gravity.
 

Realtime Ray Tracing in Freebasic

Started by Voltage, March 22, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

rdc

Awesome work.

Btw, no one needs to apologize here. I'm not miffed. Sorry if it came across that way. I was just explaining my reason for posting.

Paul

I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Voltage

@Rain_Storm:


'Specular lighting
'Texture maps
'Reflection
'Spheres
'Optimizations - Adaptive Sub-sampling/Bounding boxes/other?


The above are lines from the source code....  I will most definately be adding reflections and other various raytracing cool stuff.  But the adaptive sub sampling REALLY wet my whistle :) ... so to speak, so I implemented that first. 

My goal, and reason for attempting a real time raytracer is that I want to create a demo worthy of the elite scene.  So I will try (any probably fail many times) to create a scene worthy demo. 

So whats next? 

I think specular lighting, then relfections, then maybe refractions......  I'll keep posting code as I make progress.

@Thygrion: Have I earned the right to see your funky code yet?  Send us the goods :)
Challenge Trophies Won:

Voltage

Quotethen relfections

lol, I had a coupla wines tonight :)
Challenge Trophies Won:

Shockwave

That is quite a lot faster :D Well done voltage!
Shockwave ^ Codigos
Challenge Trophies Won:

ferris

Try doing something with spheres, because it is amazingly faster, but not realtime here.

Maybe my goals are just different :P
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

ferris

hm... I came accross a little mean there...

What I meant was it's alot faster and great work. What size squares are being used initially? I think it's just the triangles that's making it slow..if not try 8x8 squares.

Still not realtime here, but it's getting close.

This inspired me to retry accomplishing this goal in C++. I'll post some previews when I get this retarted dialog box working (with code ;) ). Hope it helps!

Keep on keeping on, this is shaping up.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

rain_storm

Spheres would be cool and I would imagine spheres to be much faster than polygons since circle and spheres can be defined simply as a distance from center point so less points to consider but then again you wanna bounce that ray off the sphere so that might be more complex keep up the good work man

Challenge Trophies Won:

ferris

right you are :)

spheres are defined by a sphere function (3D circle function).
cylinders are defined (the way I do them ;) ) by a 2D circle function and height stuff.
planes are all defined as a simple function, too.

So spheres, cylinders, and planes are all much faster primitives to trace than triangles, and actually aren't any harder to do reflections/refractions on rays, since the same math is used.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Shockwave

Spheres would be the easiest primitives to texture map too if youd thought of adding textures as you could use the latitude and longitude of the sphere to generate your uv co-ordinates..  If I had source I would gladly share it with you Voltage, unfortunately I have never written a program like this myself, I don't think Thygrion is going to share his source with you so I will look into it this week as long as I get the time.
Shockwave ^ Codigos
Challenge Trophies Won:

ferris

I would share it, but my C version isn't even a tracer yet (just a directX shell...) and my old freebasic tracers aren't accessable.

The only problem with texture mapping sheres with what you were explaining, Nick, (even though it is the best looking ;) ) is that the adaptive subsampling tends to screw it up. I've tried to fix it with no luck so far, but when I get it I'll gladly explain how :)
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

p01

Thygrion: It should look fine if you force to go one step further in the sampling grid when the area covered by one square in the U,V space is too big.

Tetra

some fine stuff youve made there, i've always been interested in raytracing, just never had the initative to give it a try. Keep it coming, great stuff :)
Challenge Trophies Won:

Clyde

Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Shockwave

Hey I'd forgotten about that post Clyde :) Nice find.
Shockwave ^ Codigos
Challenge Trophies Won:

ferris

Woot for Clyde!!

Yup, that's my first raytracer :D

Not realtime, but my code is still structured the same way (mostly ;) )

Almost got the C version done, when I finish the interpolation it should work fine.

po1: You're right, but I meant a tiling problem...it goes from like u = 256 to u = 0 in one square and gets all wierd-looking....I'll show you if I have that problem in C.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

p01

Thygrion sphere ray-casting is damn simple, and the u0=255 and u1=0 case will induce a cascade of subsampling that will solve the pb.

I've not checked if you posted your code, and never touched FreeBasic, but the sub-sampling should test ONLY the primitives found at the 4 corners so it should be pretty fast.

FWIW, I made some RTRT in C/C++ back in the days, around 98, but that was just a bunch of spheres, planes, cylinders and cones

Voltage

Thanks everyone for the info, interest and links....raytracing is addictive isn't it?

Attached is the current version:
- Added spheres
- Added specular lighting

Still to do
- FPS
- Recursive reflection
- Refraction
- Texturing
- Improve sub smapling routine - the current one is really crappy, I reckon I can at least double the speed of the tracer...

Challenge Trophies Won:

Clyde

Wow, that looks amazing dude, grand job :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

rdc