POV-Ray : Newsgroups : povray.animations : Using Animation to Generate A Ray In An Arbitrary Direction Server Time: 20 Jan 2021 16:15:20 GMT
 Using Animation to Generate A Ray In An Arbitrary Direction (Message 1 to 4 of 4)
 From: Paul Riley Subject: Using Animation to Generate A Ray In An Arbitrary Direction Date: 27 Jan 2015 02:35:01 Message:
```Thanks for receiving me into the POVRAY forum.

I first used POVRay some 20 years ago, and found it enjoyable, in an era where
3D modellers were few. I generated my geometry in AutoCAD and had fun with
rendering them.

Now I'm interested in computer generated art, and I need to able to receive the
colour for a traced ray at some arbitrary direction. Normally, POVRay will
generate a complete image of predetermined width and height. Is there a way I
can ask it to render only a single pixel in a direction of my choosing? Let me
explain why.

I have been doing distortions on 2D artwork, and the problem is that certain
areas of the 2D source art are of too low resolution. I want to start with pixel
co-ordinates in the destination image space, and apply mathematical
transformations to produce the desired camera angles in the 3D space. I would
like POVRay to return the pixel colour for these angle co-ordinates, so I can
insert that colour in my target image.

I have considered using animation within POVRay to do this, as follows. It is a
basic layman's description of what happens.

1)  POVRay opens source file and reads in all scene details.
2)  Animation clock start=0 and end = target_width * target_height - 1, and
number of frames = target_width * target_height. Every increment of the clock
variable is then a new target pixel.
3)  For each animation iteration, use the clock variable to determine which
target pixel is being rendered. Use calculations in POVRay to determine the
Delta Azimuth and Delta Elevation angles from the nominal camera direction, and
correct the camera direction to reflect this.
4) Render an image of Width = Height = 1 pixel, and save that file with a unique
name.
5) End POVRay
6) Custom program reads all of the output files in turn, reads the single pixel,
and assembles the target image, and deletes all of he POVRay output files.

This process will produce a very large number of files, which I would need to
accommodate in a RAM drive for speed reasons. It seems quite clumsy though, and
experienced POV'ers may know of a different way to achieve this.

In the normal operation of POVRay, I would imagine that the software loops
through the target pixel array, determines what the required camera (or ray)
direction is and requests the colour of that ray from the renderer. Is it
possible to interfere with that process, and create my own loop where I can
request a ray to be traced in a direction of my own choosing? i.e. when the loop
call a routine to calculate the ray direction, can it call my routine to
calculate some arbitrary direction?

Your wisdom would be well appreciated.

Thanks,

Paul
```
 From: clipka Subject: Re: Using Animation to Generate A Ray In An Arbitrary Direction Date: 27 Jan 2015 03:18:35 Message: <54c7038b\$1@news.povray.org>
```Am 27.01.2015 um 03:33 schrieb Paul Riley:

> In the normal operation of POVRay, I would imagine that the software loops
> through the target pixel array, determines what the required camera (or ray)
> direction is and requests the colour of that ray from the renderer. Is it
> possible to interfere with that process, and create my own loop where I can
> request a ray to be traced in a direction of my own choosing? i.e. when the loop
> call a routine to calculate the ray direction, can it call my routine to
> calculate some arbitrary direction?

You might want to have a closer look at the mesh camera.
```
 From: Paul Riley Subject: Re: Using Animation to Generate A Ray In An Arbitrary Direction Date: 27 Jan 2015 04:20:01 Message:
```clipka <ano### [at] anonymousorg> wrote:
> Am 27.01.2015 um 03:33 schrieb Paul Riley:
>
> > In the normal operation of POVRay, I would imagine that the software loops
> > through the target pixel array, determines what the required camera (or ray)
> > direction is and requests the colour of that ray from the renderer. Is it
> > possible to interfere with that process, and create my own loop where I can
> > request a ray to be traced in a direction of my own choosing? i.e. when the loop
> > call a routine to calculate the ray direction, can it call my routine to
> > calculate some arbitrary direction?
>
> You might want to have a closer look at the mesh camera.

Thanks for that.

If I use a regular mesh object, with simple triangles for the mesh camera, how
is the sense of the triangle's normal vector defined? I assume that the normal
vector is the unit vector of the cross product of two of the side vectors. If
so, which ones? If the three vertices are a, b and c, then is the normal vector
ab x bc or is it bc x ab?

Paul
```
 From: MichaelJF Subject: Re: Using Animation to Generate A Ray In An Arbitrary Direction Date: 27 Jan 2015 07:40:00 Message:
```"Paul Riley" <nomail@nomail> wrote:

>
> If I use a regular mesh object, with simple triangles for the mesh camera, how
> is the sense of the triangle's normal vector defined? I assume that the normal
> vector is the unit vector of the cross product of two of the side vectors. If
> so, which ones? If the three vertices are a, b and c, then is the normal vector
> ab x bc or is it bc x ab?
>
> Paul

Better specify the normals yourself. May be not the easiest task, but this way
you gain control over the normals.

Best regards,
Michael
```