Where to begin with RayTracing?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Where to begin with RayTracing?

Post by iPoisonxL »

Hello! I am completely and utterly knowledge-less with Raytracing and any shadow stuff and shaders. I was wondering, where should I begin? How do I learn to create a simple raytracing test with squares and a point and shadows? Also, how would I use this to make 3D stuff?

I've tried making 3D things before but I just failed terribly. What's the most efficient way? Can somebody explain to me how translating 3D to a 2D plane works? Can somebody explain to me how raytracing works? Or at least point me in the right direction with articles that aren't advanced (orientated for beginners)?'

edit: Raycasting, I mean
Last edited by iPoisonxL on Sun Dec 21, 2014 3:28 pm, edited 1 time in total.

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Where to begin with RayTracing?

Post by undef »

For starting out, I'd recommend brewing some nice Tea, getting some snacks ready and watching this keynote by John Carmack:

Principles of Lighting and Rendering with John Carmack at QuakeCon 2013


(watch on youtube to enable fullscreen)

This gives you a nice overview how everything works, and what to look for if you want to dig in deeper.
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Where to begin with RayTracing?

Post by Roland_Yonaba »

Hi,

I might have a couple of links that can be helpful.
RayTracing is a quite wide topic. I do not have a great experience on the topic, nubut I remember having played with it a while back.
I just found those old articls I used at that time to learn the topic.
Raycasting tutorial on lodev
F. Permadi's tutorial series on Raycasting

Also, I have two unfinished implementations on github, that you can take a look at. See smallpt-lua (which is a Lua port of the original small-pt raytracer) and raytracer. You can also search on Github using the keyword "raytracer" or "raytracing", there are dozens of them. Make sure to checkout Minilight, it is a global illumination raytracer written in Haxe, and ported in lots of languages. It is fast, and very well written.

Hope this helps.
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Where to begin with RayTracing?

Post by iPoisonxL »

Thanks both of you, I'm looking into the tutorials and video now.

edit: I'm trying to understand these, but I'm just not able to write it down in lua.
This is ultimately what I'm trying to achieve:
Image
I didn't make this but it's in my folders for reference, except this uses shaders. I don't want to use shaders, and if I must I'd like a proper shader tutorial that I can't find anywhere.

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: Where to begin with RayTracing?

Post by Muris »

I was trying to do something what you have in the picture, although the code I did for LUA is pretty much vommit, tons of globals etc, but here is the code. It probably also has some strange debug output not to mention finnish names I think. It was one of those first lines I did write in LUA. Although I don't think that is exactly what I would call raytracing.

I think raytracing means that you are kind of doing inverse traveling from monitor to forward. Then trying to value the color of the pixel based on the object the ray hits and from that point trying to calculate all possible directions light would travel from to that point. Well I think other people can explain / know it better.

Anyways here is my version of trying to count if line a overshadows other lines. It seems to have some bugs too + it probably isnt even what youre looking for. And like said its very unoptimized and horrible terrible code to read.
Attachments
weird_light_thingy.love
(7.59 KiB) Downloaded 124 times
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Where to begin with RayTracing?

Post by iPoisonxL »

Muris wrote:I was trying to do something what you have in the picture, although the code I did for LUA is pretty much vommit, tons of globals etc, but here is the code. It probably also has some strange debug output not to mention finnish names I think. It was one of those first lines I did write in LUA. Although I don't think that is exactly what I would call raytracing.

I think raytracing means that you are kind of doing inverse traveling from monitor to forward. Then trying to value the color of the pixel based on the object the ray hits and from that point trying to calculate all possible directions light would travel from to that point. Well I think other people can explain / know it better.

Anyways here is my version of trying to count if line a overshadows other lines. It seems to have some bugs too + it probably isnt even what youre looking for. And like said its very unoptimized and horrible terrible code to read.
Sadly this is all I'm getting
Image

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: Where to begin with RayTracing?

Post by Muris »

I guess that is what I get when I try to pull bad code out of bigger portion. I forgot to disable the wasd-keys. Basically the whole point of the thing is just to kind of calculate the "light" area when you drag lines (set walls) with left mouse button. You can turn the light area with right mouse. The whole thing is a test if I can somehow figure out if an object is shadowed by another object, which in this case would be lines (= walls). Later on I was planning to change that into polygons, but I kind of got distracted by something else and forgot the whole project.

What I was trying to accomplish was something of a line of sight thing on a 2d top-down stealth type of a game, where npcs would be guarding something and you would want to avoid being detected and you could move behind various walls or objects.
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Where to begin with RayTracing?

Post by iPoisonxL »

Muris wrote:I guess that is what I get when I try to pull bad code out of bigger portion. I forgot to disable the wasd-keys. Basically the whole point of the thing is just to kind of calculate the "light" area when you drag lines (set walls) with left mouse button. You can turn the light area with right mouse. The whole thing is a test if I can somehow figure out if an object is shadowed by another object, which in this case would be lines (= walls). Later on I was planning to change that into polygons, but I kind of got distracted by something else and forgot the whole project.

What I was trying to accomplish was something of a line of sight thing on a 2d top-down stealth type of a game, where npcs would be guarding something and you would want to avoid being detected and you could move behind various walls or objects.
That's neat, I like it. But I feel RayTracing like this would be quite difficult

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: Where to begin with RayTracing?

Post by Muris »

If you are first looking for casting shadows in 2D, not 3D, i think these videos explains the idea behind the shadowcasting pretty well.


But I don't fully understand what you are trying to do. 2D or 3D. Also raytracing and shadow casting are kind of different things, but if your goal is to do something like you had in the picture, then you should go with shadow casting, which is something like this project: viewtopic.php?f=5&t=78998

If you are on the otherhand going for raytracing, that is completely a different thing.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Roland Chastain and 238 guests