POV-Ray : Newsgroups : povray.general : Not grokking mesh camera : Re: Not grokking mesh camera Server Time 9 Aug 2024 18:56:39 EDT (-0400)
 Re: Not grokking mesh camera
 From: Chris Cason Date: 30 Apr 2023 08:08:50 Message: <644e5a52\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#644e5a52%241%40news.povray.org",
"headline": "Re: Not grokking mesh camera",
"dateCreated": "2023-04-30T12:08:50+00:00",
"datePublished": "2023-04-30T12:08:50+00:00",
"author": {
"@type": "Person",
"name": "Chris Cason"
}
}
On 30/04/2023 12:30, Josh English wrote:
> I am trying to understand the mesh camera and picking apart the demo scenes but I'm
just not getting something.

It's a long time since I wrote the mesh camera code, so please excuse me if my memory
is rusty, but I'll try to answer.

The following applies to distribution methods 0, 1 and 2:

> The normal vector of the triangle determines the direction of the ray for that
pixel.

Yes, with the consideration that if the camera Z direction is less than 0, the normal
is reversed.

> Does the position of the mesh also determine the location of the ray?

Yes, with the caveat that the Z location of the camera is then used to offset the
ray's origin along its direction.

> A second question: is the first triangle in the mesh the upper left corner of the
image or bottom left corner?

Upper left. The face index is mapped as y * width + x, where y, width and x are all
first mapped to unsigned int.

> A third question: does the ray start at the first vector in each triangle?

No, it's shot from the triangle's centroid.

Distribution 0 is single or multiple rays per pixel, with each additional ray going to
the next mesh in the sequence in which they were declared.

Distribution 1 is 1:1 distribution across summed meshes, potentially with multiple
rays per pixel. The faces of all the supplied meshes are logically summed together as
if they were one single mesh. If shooting multiple rays per pixel, the face index is
determined as (width * height * ray_number) + pixel_number.

Distribution 2 is multiple logical cameras, placed side-by-size horizontally, with
mesh #0 being the left-most camera, and mesh #n is the right-most. Rays per pixel is
ignored.

I won't cover distribution 3 here as it's quite different from the above.

I also suggest that, if you haven't already done so, you take a look at Jaime's mesh
camera page at http://www.ignorancia.org/index.php/technical/mesh-camera/. He's also
posted some other examples here in the groups, e.g.