Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   WIP: My Raytracer (https://simplymaya.com/forum/showthread.php?t=20118)

MattTheMan 03-02-2006 09:29 PM

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 :alien:

MattTheMan 04-02-2006 01:19 AM

Hmm.. seems VERY hard. I don't know where to start. It will be a while before my first update.

MattTheMan 04-02-2006 02:29 AM

1 Attachment(s)
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.

MattTheMan 09-02-2006 01:16 AM

1 Attachment(s)
Yay! I got some work done! Here is a screenshot (just some normal calculations)

MattTheMan 10-02-2006 02:43 AM

1 Attachment(s)
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

MattTheMan 10-02-2006 02:57 AM

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....

MattTheMan 11-02-2006 07:50 PM

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 :alien:
Update soon.

Tim_LIVID 11-02-2006 08:59 PM

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.

MattTheMan 11-02-2006 09:41 PM

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 :(

cya later,
Matt :alien:

MattTheMan 11-02-2006 10:08 PM

1 Attachment(s)
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!

MattTheMan 12-02-2006 12:30 AM

1 Attachment(s)
OH! OH YEAH! Take a look at the following tightness! I'm on a roll!:attn: :attn:

Tim_LIVID 12-02-2006 10:41 AM

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.

MattTheMan 12-02-2006 03:32 PM

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.

MattTheMan 12-02-2006 09:17 PM

1 Attachment(s)
update - the pic explains itslef

magicsy 12-02-2006 09:24 PM

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.


All times are GMT. The time now is 08:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018