Noobie needs help with view plane :oops: back

(L) [2006/02/28] [Pon] [Noobie needs help with view plane :oops:] Wayback!

Ok, I've got almost everything done for the first version of my ray tracing engine. The only thing I'm stuck with is the view rectangle. If it were to have any arbitrary position and orientation (including roll), what is the general maths to get a point to project my ray through? I know that Phantom's original code did this:
(L) [2006/02/28] [lycium] [Noobie needs help with view plane :oops:] Wayback!

there are many tutorials for this on the net (i think?), but i thought i could quickly haxxor together a little diagram with some essential infos...


[IMG #1 ]
[IMG #1]:Not scraped: https://web.archive.org/web/20061004002320im_/http://mysticgd.com/thomas/slinkyspace/viewplane.gif
(L) [2006/02/28] [Pon] [Noobie needs help with view plane :oops:] Wayback!

Thanks heaps [SMILEY Very Happy]


I love your avatar by the way  [SMILEY Twisted Evil]
(L) [2006/02/28] [lycium] [Noobie needs help with view plane :oops:] Wayback!

hehe thanks, one finds all sorts of strange pics on the net ;)


btw that topmost eq is a bit misinformative, i gave p_0 in terms of f, u and r, but the u and r vecs need to be scaled such that


x_vec = r * 2tan(fov/2)

y_vec = u * 2tan(fov/2) * 3/4 (or whatever aspec ratio you use)


then


p_0 = o + f + y_vec/2 - x_vec/2

d_x = x_vec/xres

d_y = y_vec/yres


p_(x,y) = p_0 + d_x*x - d_y*y


also tan(fov/2) spans only half the viewplane x-direction, i drew it totally incorrectly :/


btw be sure to post your first ray traced pics! :D
(L) [2006/03/01] [Pon (not logged in :/)] [Noobie needs help with view plane :oops:] Wayback!

Heh, I shall.


Ok, I have fully created my ray tracer library... Now to create the application  [SMILEY Evil or Very Mad]
(L) [2006/03/01] [lycium] [Noobie needs help with view plane :oops:] Wayback!

dunno why you're being so large-scale about your first tracer, it's quite possible to get a little shadowing checkerboard/sphere thing going in a few (40?) lines of code :)
(L) [2006/03/01] [Pony] [Noobie needs help with view plane :oops:] Wayback!

40?


[SMILEY Embarassed] I've written like... 5000 lines I think [SMILEY Confused] [SMILEY Confused]
(L) [2006/03/01] [Pony should log in.] [Noobie needs help with view plane :oops:] Wayback!

PLUS it gets stack overtflows  [SMILEY Rolling Eyes]
(L) [2006/03/01] [lycium] [Noobie needs help with view plane :oops:] Wayback!

that's insane! like, what does it do?
(L) [2006/03/01] [Guest] [Noobie needs help with view plane :oops:] Wayback!

Basically I've made heaps of classes like "Point" "Sphere" of course, but other stuff like "AreaLight" "PointLight" "NonVolume" etc... And a few interfaces. A camera class, renderer class, a render surface, etc... And it doesn't work  [SMILEY Razz]


It is pretty much using MDX for its dirty work like intersection and stuff.
(L) [2006/03/01] [lycium] [Noobie needs help with view plane :oops:] Wayback!

hmm that's not really raytracing at all methinks :/ no offense or anything but, why use a library for the important stuff, then design wrappers around it that don't work?


beyond a little vector class (which is important that you write for const correctness etc) you shouldn't need very much besides 2 tracing methods and some image output stuff to get started. 40 lines :)
(L) [2006/03/01] [Pon] [Noobie needs help with view plane :oops:] Wayback!

Heh, nah the vector classes and stuff like that are so in the future I can not use MDX, and the interfaces (like my Intersectable interface) are so that any object can be tested... I'm mainly using MDX to get it up and running...   [SMILEY Crying or Very sad]
(L) [2006/03/01] [Pon] [Noobie needs help with view plane :oops:] Wayback!

Heh, well, as I said, I'm rather noobish at this [SMILEY Very Happy]

back