Author Topic: Realtime Ray Tracing in Freebasic  (Read 49314 times)

0 Members and 1 Guest are viewing this topic.

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Realtime Ray Tracing in Freebasic
« Reply #20 on: March 24, 2007 »
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.

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: Realtime Ray Tracing in Freebasic
« Reply #21 on: March 24, 2007 »
Nice, very fast indeed :)
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: Realtime Ray Tracing in Freebasic
« Reply #22 on: March 24, 2007 »
@Rain_Storm:

Code: [Select]
'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:

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: Realtime Ray Tracing in Freebasic
« Reply #23 on: March 24, 2007 »
Quote
then relfections

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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Realtime Ray Tracing in Freebasic
« Reply #24 on: March 24, 2007 »
That is quite a lot faster :D Well done voltage!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Realtime Ray Tracing in Freebasic
« Reply #25 on: March 24, 2007 »
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:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Realtime Ray Tracing in Freebasic
« Reply #26 on: March 24, 2007 »
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:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Realtime Ray Tracing in Freebasic
« Reply #27 on: March 24, 2007 »
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:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Realtime Ray Tracing in Freebasic
« Reply #28 on: March 24, 2007 »
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:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Realtime Ray Tracing in Freebasic
« Reply #29 on: March 25, 2007 »
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:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Realtime Ray Tracing in Freebasic
« Reply #30 on: March 25, 2007 »
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:

Offline p01

  • Atari ST
  • ***
  • Posts: 158
  • Karma: 51
    • View Profile
    • www.p01.org
Re: Realtime Ray Tracing in Freebasic
« Reply #31 on: March 25, 2007 »
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.

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Realtime Ray Tracing in Freebasic
« Reply #32 on: March 26, 2007 »
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:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Realtime Ray Tracing in Freebasic
« Reply #33 on: March 26, 2007 »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Realtime Ray Tracing in Freebasic
« Reply #34 on: March 26, 2007 »
Hey I'd forgotten about that post Clyde :) Nice find.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: Realtime Ray Tracing in Freebasic
« Reply #35 on: March 26, 2007 »
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:

Offline p01

  • Atari ST
  • ***
  • Posts: 158
  • Karma: 51
    • View Profile
    • www.p01.org
Re: Realtime Ray Tracing in Freebasic
« Reply #36 on: March 26, 2007 »
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

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: Realtime Ray Tracing in Freebasic
« Reply #37 on: March 27, 2007 »
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:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Realtime Ray Tracing in Freebasic
« Reply #38 on: March 27, 2007 »
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:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Realtime Ray Tracing in Freebasic
« Reply #39 on: March 27, 2007 »
Looking good.