programing a raytracer

Discuss stuff not about Indigo.
User avatar
OnoSendai
Developer
Posts: 6243
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Post by OnoSendai » Mon Mar 19, 2007 4:28 am

If you're new to programming, u might want to check out some raytracing code i created a while back:
http://homepages.paradise.net.nz/nickam ... tracer.htm
it's nice and simple, not like Indigo :)
(altho there's probly some shared source code :) )

EDIT: it's in C++, not Java.. but at least the raytracing portion should be similar.

User avatar
eman7613
Posts: 597
Joined: Sat Sep 16, 2006 2:52 pm

Post by eman7613 » Wed Mar 21, 2007 6:31 pm

just stumbled upon this, thought it might help

http://www.superjer.com/pixelmachine/
Yes i know, my spelling sucks

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Thu Mar 22, 2007 3:30 am

eman:

that's a great link, and exactly how my mind works (as per my previous suggestions in this thread) thanks!

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Tue Apr 17, 2007 2:29 pm

i have finally produced an image of a sphere with shading with my raytracer. i am pleased. most of the time was spent finding a suitable way to initiate the camera and calculate the points of the pixels based on the camera's location and its film width. then there was that little setback of knowing practicaly nothing about linear algebra. now i feel really special. thanks for the links people.
a shiny monkey is a happy monkey

User avatar
manitwo
Posts: 1029
Joined: Wed Jul 05, 2006 4:50 am
Location: Tirol - Austria

Post by manitwo » Tue Apr 17, 2007 2:41 pm

show us! :wink:

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Tue Apr 17, 2007 2:50 pm

because I'm going to use it on my college app and other apps, i cant show you the source, but here is an image:
Image
a shiny monkey is a happy monkey

mrCarnivore
Posts: 517
Joined: Sun Mar 04, 2007 6:20 am
Location: Stuttgart, Germany

Post by mrCarnivore » Tue Apr 17, 2007 9:13 pm

Nice!!

Congratulations to your first succesful render with your very own render engine!

Hoooray! 8)

User avatar
eman7613
Posts: 597
Joined: Sat Sep 16, 2006 2:52 pm

Post by eman7613 » Wed Apr 18, 2007 2:05 am

mazel tov!
Congrats.
Yes i know, my spelling sucks

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Wed Apr 18, 2007 6:28 am

looks GREAT :D
Is that plane infinite, too?

How long did you need to render it?

congrats!

is there a bug on the lower edge of the sphere?
there are some brighter pixels!

IanT
Posts: 153
Joined: Fri Aug 25, 2006 3:13 am

Post by IanT » Wed Apr 18, 2007 8:11 am

Excellent :D I'm guessing that took only a few seconds to render (anti-aliased too by the look of it)

Ian.

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Wed Apr 18, 2007 3:04 pm

yah, there was a bug in the phong shading in the lower part of the sphere. since (five miniutes after the post) i realized that i had to clip my colors after phong. It has AA, its actualy realy easy to do in java- just set the image to render x larger than you want then scale it down size/x with a sampling algorithm of x acuracy. i discovered that if you do the sampling algorithm twice and only scale it down 1/2 x each time, you get much more accuracy.
i just finished adding painters algorithm to acount for multiple objects, added multiple the ability to have multiple lights and fixed the phong equations a bit. i still think there is a problem with how the specular is calculated in my phong. but as of now i don't have enough time to fix it. the color in the background is not an infinite plane, its actually a color system that i set up that finds the angle of the camera - pixel ray compared to camera -point ray that i was using to help me see if the camera was set up properly and all my vector stuff was working. -the dark in the back is not shadow, i don't have that yet, although both shadows and planes need only a couple more lines of code. that image only took maybe a two or three seconds to render.
best thing about this is my new ability to go up to people and completely confuse them with concepts and algorithms they have never heard of before.

newest image:

Image
a shiny monkey is a happy monkey

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Thu Apr 19, 2007 12:15 am

I'm not confused, yet ;)
Great image :D aleady a lot better ;)
Your AA-technic isn't AA, as far a I know, ut OSA, which has the same effect, but works differently...
OverSAmpling :D

How did you get these strange, but good looking grren parts on the dark side of the red sphere?

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Thu Apr 19, 2007 1:37 am

the green part is not intentional, i am currently trying to figure out why that happened.
a shiny monkey is a happy monkey

User avatar
eman7613
Posts: 597
Joined: Sat Sep 16, 2006 2:52 pm

Post by eman7613 » Thu Apr 19, 2007 2:34 am

If you are drawing the image with the 2d api provided by java, it has a built in function for AA if i remember correctly that is very good. Dont take me word for it though, i hate programing graphics and try to avoid it at all costs ;p
Yes i know, my spelling sucks

IanT
Posts: 153
Joined: Fri Aug 25, 2006 3:13 am

Post by IanT » Thu Apr 19, 2007 2:54 am

eman7613 wrote:If you are drawing the image with the 2d api provided by java, it has a built in function for AA if i remember correctly that is very good. Dont take me word for it though, i hate programing graphics and try to avoid it at all costs ;p
I think the above only applies to 2D primitives (e.g. smoothing the edges of a circle primitive), which won't be applicable in this case.

Rather than rendering the image at 4x4 resolution then down-scaling, a quicker way to do simple AA is to render it at normal resolution then scan the resulting image for pixels with high local contrast. Then just create more samples for that pixel and replace it with the averaged result.

Ian.

Post Reply
164 posts

Who is online

Users browsing this forum: No registered users and 28 guests