Integrating 3D models with photography
Interested in integrating your 3D work with the real world? This might help
# 1 03-02-2006 , 09:29 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436

WIP: My Raytracer

Ok, this is a work in progress. I am programming a raytracer in c++. I will post a first update tonight, with diffuse shading. I will be using two lights, and will mostly be working along with the method described at www.flipcode.com, an excellent tutorial for raytracer programming.

This will include diffuse lighting, reflections, phong effects, refractions, soft shadows, fixed grid spatial subdivisions, and diffuse reflections.

Then I will do some research and apply things like LDR Image Based lighting, Monte Carlo GI, caustics, and KD-Tree tracing algorithms. Finally, I will add skylights, object lights, and, possibly, polygon handling on basic things like cubes, cylinders, and spheres.

Also, I will be posting up sections of my code for help and stuff. I know a bunch of you peeps are programmers, so I can use the help (im 13 :p).

As for the algorithms, I will just be applying the best ones I find, since I have very little knowledge of linear algebra, and the only formula I know is the reflection one: R= V*2 - (V dotproduct N) * N

Alright, then, update tonight.

EDIT: I am biting off a heck of a lot more then I can chew. But I will not quit. I am not a quitter

cya later,
Matt user added image


Live the life you love, love the life you live

Last edited by MattTheMan; 03-02-2006 at 10:49 PM.
# 2 04-02-2006 , 01:19 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Hmm.. seems VERY hard. I don't know where to start. It will be a while before my first update.


Live the life you love, love the life you live
# 3 04-02-2006 , 02:29 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Alright, I started coding. I'm doing this for all of the vector classes (no matrices yet) including ray, camera, and primitives.
also I have the color definition and the color on screen stuff done too
Here is what I am aiming for, as a first goal: this is done in Maya

a sphere, with diffuse shading.

edit\\ Alright, so I got some algorithms from the nice people at CGtalk.com, for normal calculating, and also I figured out my previos problem with the vector extrusion.

Attached Thumbnails

Live the life you love, love the life you live

Last edited by MattTheMan; 05-02-2006 at 06:09 PM.
# 4 09-02-2006 , 01:16 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Yay! I got some work done! Here is a screenshot (just some normal calculations)

Attached Thumbnails

Live the life you love, love the life you live
# 5 10-02-2006 , 02:43 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Hmmm... can't say I'm satisfied, this does work... but not so great.
It tests if a point is on a plane or not. I'm pretty sure this is wrong, I will try normalizing all vectors first, that might give me more accurate results, and I will post my results

Attached Thumbnails

Live the life you love, love the life you live
# 6 10-02-2006 , 02:57 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Yeeah... I will have to rewrite that code, its seriously f***ed up. I think it does sumthing much more advanced then what I want it to do :p, and takes it as not an infinite plane, but instead as a LINE between the two vectors(which its processing as points).

Oh, DUH!!!! I'm only taking into account the two vectors for the cross product for the normal! I'm using the WRONG PLANE EQUATION!!!! :headbang: will fix tomorrow....


Live the life you love, love the life you live
# 7 11-02-2006 , 07:50 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Alright, now everything, instead of working with a ton of floats, works with the typedef class

vector3d{
public: float x, float y, float z
};

And all of the funcs, instead of taking (example)

DOT(float ax, float ay, float az, float bx, float by, float bz)

it takes

DOT(vector3d V, vector3d, U).

This is a whole lot faster on me, like when I have the following function

RectAndL-Intersect(float ax, float ay, float az, float bx, float by, float bz, float cx, float cy, float cz, float dx, float dy, float dz, float testx, float testy, float testz)

Which took 15 float values. Instead, now it works like:

RectAndL-Intersect(point A, point B, point C, point D, point Test)

Still takes 15 float values, but they are stored inside 5 point values. Point values have

typdef class point{
public: float x, y, z;
};

Next up: Point-Plane tests, followed by Ray-Plane intersection tests, my first intersection tests!

Cya Later Peeps,
Matt user added image
Update soon.


Live the life you love, love the life you live
# 8 11-02-2006 , 08:59 PM
Tim_LIVID's Avatar
Subscriber
Join Date: Sep 2003
Location: Harwich, UK
Posts: 1,195
I can appreciate the skill that is involved but I have to ask the question ... why are you doing this?

It seams a case of reinventing the wheel.


"You can live for yourself today -- or help build tomorrow for everyone" _LIVID

Optical Minefield
My Blog
# 9 11-02-2006 , 09:41 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Yeah... see this is in the programming TO DO list on everyone that's learning c++. It gives a fine grasp of c++, using all of its functions, as well as giving the programmer more of an understanding of linear algebra.

In most programming courses at uinversities or colleges, programming a raytracer is something that they have to do, and often its within the first month or two of class.

So, basically, I want to understand c++ and linear algebra/vector calculus better, and also, I find it kinda fun, doing this reinventing the wheel thing. :p

Update to come... my point-plane function is saying everything is on a plane user added image

cya later,
Matt user added image


Live the life you love, love the life you live
# 10 11-02-2006 , 10:08 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
It works! So happy :attn: :attn: !
I won't test it in too many directions, because I can't calculate that much in my head to verify if its right or wrong.

Also, at first, all I will use this for will be directly on an axis, and first as an infinite ground plane.

Next up: Ray-Plane intersection tests!

Attached Thumbnails

Live the life you love, love the life you live
# 11 12-02-2006 , 12:30 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
OH! OH YEAH! Take a look at the following tightness! I'm on a roll!:attn: :attn:

Attached Thumbnails

Live the life you love, love the life you live
# 12 12-02-2006 , 10:41 AM
Tim_LIVID's Avatar
Subscriber
Join Date: Sep 2003
Location: Harwich, UK
Posts: 1,195
I'm sorry, I use to be a programmer years ago but this means nothing to me. I'm sure it's very good.

Maybe when you have finished it you could upload it and we could all give it a test.


"You can live for yourself today -- or help build tomorrow for everyone" _LIVID

Optical Minefield
My Blog
# 13 12-02-2006 , 03:32 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
sure, yeah, but very soon I will have my first image, with a sphere and a plane

and of course I will upload it here

\\edit The ray-plane intersection right now can tell if the ray really hits, like a car going foreward and hitting a truck, or if it is just Not Paralell to the plane, but really doesn't intersect the plane in the direction it was going.


Live the life you love, love the life you live

Last edited by MattTheMan; 12-02-2006 at 03:48 PM.
# 14 12-02-2006 , 09:17 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
update - the pic explains itslef

Attached Thumbnails

Live the life you love, love the life you live
# 15 12-02-2006 , 09:24 PM
magicsy's Avatar
Subscriber
Join Date: Oct 2005
Location: Leeds
Posts: 1,154
hey matt lost me with this one but i have a question for you, how come i never seem to see you working on anything. i apart from ure wacom u did i aint really seen any of ure work hope u start gettin some up in the Wip.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads