0
$\begingroup$

Recently I've became an intern in company-name and my internship task is(for now) create rasterization using rays.

I'm mostly interested in pure math, so basic ideas on how to do it I've caught up really fast: I need to find an intersection of a ray that starts in center of a pixel with a plane of a triangle, compute barycentric coordinates in order to understand whether the intersection point is in the triangle or not.

But when it comes to code realization, I'm getting stuck.

First of all, and probably my main "problem" is that I can't really understand what "camera" is really about. I know it might have a lot of different properties(so called "intrinsic" and "extrinsic"), but I just need a basic one. For now I understand this as an "eye" located somewhere in the space.

And here is the second "problem": I said, the camera is located somewhere in the space, but where is it really located? I really can't get how to put in in the space. Also, I need to put the "screen" somewhere in the space as well, preferably between the "eye" and object/scene(I'm considering pinhole camera as a primer model).

For now, I do the following: I identify "eye" and "screen" as one object(going down to biology, "screen" is something like the cornea of a human eye). I scale my object/scene in $[-1,1]^3$, and put my "eye"/"screen" on the 2-sphere of radius $2\sqrt3$, because $[-1,1]^3$ is inside of this sphere. Therefore I can move my "camera" on the sphere, getting different camera positions. But I'm not quite sure that this is how it should be done.

So this are my problems, basically about the essence of camera(and so of screen) and its positions in the space. I hope someone will help me to tackle my confusion. Thanks.

$\endgroup$
11
  • $\begingroup$ Welcome to CG. I think it would be beneficial if you summarize what you are asking in the title or at the end of your question. Maybe it is just me being tired, but I had to re-read your question several times to get a clue what you are asking. $\endgroup$
    – wychmaster
    May 6, 2021 at 21:41
  • $\begingroup$ You can represent your camera as you like. The simplest one is a pinhole camera. You have an origin $\vec{o}$ and a film $\vec{S}(u,v) = \vec{o} + z\vec{f} + u \vec{e}_1 + v\vec{e}_2$, where $\vec{f}$ is the forward vector of your camera, $z$ is the zoom, and $\vec{e}_1, \vec{e}_2$ are the edge vectors of the film. I typically produce a mapping from $[0,W] \times [0,H]$ to $[-W/H, W/H] \times [-1,1]$ which gives me $(u,v)$ for every pixel. Having this you construct the ray $(\vec{o}, \vec{S}(u,v) - \vec{o})$. You may also generate multiple samples within a pixel, but let's ignore that for now. $\endgroup$
    – lightxbulb
    May 6, 2021 at 21:45
  • 1
    $\begingroup$ @wychmaster, thank you! I edited the title. Well, probably the question is really messy, sorry for this, I'll try to fix it with the fresh mind asap $\endgroup$ May 6, 2021 at 21:45
  • $\begingroup$ @lightxbulb, can you elaborate a bit: considering the pinhole camera, I basically have an origin and a film. This construction is determined by an origin vector(basically a point in affine space), direction vector and basis vectors of a film. But where is this construction located in $\mathbb{R}^3$? Could it possibly be "inside" an object? $\endgroup$ May 6, 2021 at 21:49
  • 1
    $\begingroup$ As already mentioned by @lightxbulb , elongated comment discussions are usually discouraged and should be moved to the chat. However, since we already have quite a lot of comments, just go on and try to solve the problem. Once you got there, consider writing an answer containing all the information you gathered in the comments. I will do the cleanup afterwards. $\endgroup$
    – wychmaster
    May 7, 2021 at 21:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.