POV-Ray : Newsgroups : povray.binaries.images : Playing with the mesh camera Server Time
7 May 2024 05:35:36 EDT (-0400)
  Playing with the mesh camera (Message 6 to 15 of 26)  
<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Kenneth
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 11:45:00
Message: <web.64679558df2a87159b4924336e066e29@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:

> >
> I've been trying to build up a tutorial on some special effects. I've
> managed a somewhat decent motion blur and focal blur, and a "portal"
> effect where one part of the image is in a different space than the rest.
>

The more I play with the meshcam demo scenes, the more fascinating it all gets!

I'm still working on the stereo red/cyan anaglyph idea (and its problems, ha),
but meanwhile, here are some of my own motion-blur experiments. I used the
'meshcam_persp_demo' file, with aa_samples=40.

In that code-- in the mesh-camera's #while loop-- I simply changed
            #declare c_look_at_tmp=...
 to
            #declare c_look_at_tmp=c_look_at;

 then following that:
            mesh{camera_mesh
            translate .008*i_samples*x // (or any x,y,z combination!)
            // and/or...
            rotate .8*i_samples*z
            meshcam_placement(c_location,c_look_at_tmp)
                }

This works because the camera mesh, as first constructed in
'meshcam_macros.inc', is apparently made facing +z and is centered on the origin
(well, it's a bit more complicated than that.) So any translations or rotations
here come *before* the mesh(es) are re-positioned and re-oriented by the
'meshcam_placement(...)' macro. Simple! But it took me quite awhile to
understand how the mesh camera and its mesh work together, in the various
includes.

BTW, only one triangle mesh is actually constructed; all of the others used in
the meshcam camera are just copies.

---------------
I'll follow up with some more notes and images of my stereogram tests and
instantiated meshes...


Post a reply to this message


Attachments:
Download 'meshcam_motion_blur_tests_kenw.jpg' (66 KB)

Preview of image 'meshcam_motion_blur_tests_kenw.jpg'
meshcam_motion_blur_tests_kenw.jpg


 

From: Mike Miller
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 13:35:00
Message: <web.6467b278df2a87153bb576b5dabc9342@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> Josh English <Jos### [at] joshuarenglishcom> wrote:
>
> > >
> > I've been trying to build up a tutorial on some special effects. I've
> > managed a somewhat decent motion blur and focal blur, and a "portal"
> > effect where one part of the image is in a different space than the rest.
> >
>
> The more I play with the meshcam demo scenes, the more fascinating it all gets!
>
> I'm still working on the stereo red/cyan anaglyph idea (and its problems, ha),
> but meanwhile, here are some of my own motion-blur experiments. I used the
> 'meshcam_persp_demo' file, with aa_samples=40.
>
> In that code-- in the mesh-camera's #while loop-- I simply changed
>             #declare c_look_at_tmp=...
>  to
>             #declare c_look_at_tmp=c_look_at;
>
>  then following that:
>             mesh{camera_mesh
>             translate .008*i_samples*x // (or any x,y,z combination!)
>             // and/or...
>             rotate .8*i_samples*z
>             meshcam_placement(c_location,c_look_at_tmp)
>                 }
>
> This works because the camera mesh, as first constructed in
> 'meshcam_macros.inc', is apparently made facing +z and is centered on the origin
> (well, it's a bit more complicated than that.) So any translations or rotations
> here come *before* the mesh(es) are re-positioned and re-oriented by the
> 'meshcam_placement(...)' macro. Simple! But it took me quite awhile to
> understand how the mesh camera and its mesh work together, in the various
> includes.
>
> BTW, only one triangle mesh is actually constructed; all of the others used in
> the meshcam camera are just copies.
>
> ---------------
> I'll follow up with some more notes and images of my stereogram tests and
> instantiated meshes...

Wow...that is very cool. Great as a motion blur.


Post a reply to this message

From: Josh English
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 16:03:56
Message: <6467d62c$1@news.povray.org>
On 5/19/2023 8:43 AM, Kenneth wrote:

> The more I play with the meshcam demo scenes, the more fascinating it all gets!
> 
> I'm still working on the stereo red/cyan anaglyph idea (and its problems, ha),
> but meanwhile, here are some of my own motion-blur experiments. I used the
> 'meshcam_persp_demo' file, with aa_samples=40.
> 
> In that code-- in the mesh-camera's #while loop-- I simply changed
>              #declare c_look_at_tmp=...
>   to
>              #declare c_look_at_tmp=c_look_at;
> 
>   then following that:
>              mesh{camera_mesh
>              translate .008*i_samples*x // (or any x,y,z combination!)
>              // and/or...
>              rotate .8*i_samples*z
>              meshcam_placement(c_location,c_look_at_tmp)
>                  }
> 
> This works because the camera mesh, as first constructed in
> 'meshcam_macros.inc', is apparently made facing +z and is centered on the origin
> (well, it's a bit more complicated than that.) So any translations or rotations
> here come *before* the mesh(es) are re-positioned and re-oriented by the
> 'meshcam_placement(...)' macro. Simple! But it took me quite awhile to
> understand how the mesh camera and its mesh work together, in the various
> includes.
> 
> BTW, only one triangle mesh is actually constructed; all of the others used in
> the meshcam camera are just copies.
> 
> ---------------
> I'll follow up with some more notes and images of my stereogram tests and
> instantiated meshes...
> 

The placement macro JVP has is pretty good, but it fails to adjust for a 
sky vector. I've spent a couple of weeks getting that to work.

These look really good. I'm amazed at how fast it processes multiple 
rays for each pixel. At least, it seems to me to be pretty fast.

Josh


Post a reply to this message

From: Kenneth
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 18:15:00
Message: <web.6467f4b7df2a87159b4924336e066e29@news.povray.org>
> [Kenneth wrote:]
> meanwhile, here are some of my own motion-blur experiments. I used the
> 'meshcam_persp_demo' file, with aa_samples=40.

> [Mike Miller wrote:]
> Wow...that is very cool. Great as a motion blur.

Thanks. It's a lot of fun to play around with. I also *think* that the blur
effect is distance-based-- that is, objects nearer the mesh camera are blurred
more than distant objects. I haven't tried a different scene to confirm that,
although it seems to follow from the fact that the camera's 40 meshes are
essentially just translated sideways a little bit. Like having 40 'eyes', but
spread out over a small 'interocular distance' in total. So distant objects
should have much less blur, just as they would have much less 3-D depth in a
human stereo view.

> [Josh wrote:]
>
> These look really good. I'm amazed at how fast it processes multiple
> rays for each pixel. At least, it seems to me to be pretty fast.
>
Same here. The rendering speed might be due to there being only one 'created'
mesh, which is then used multiple times. I think a triangle mesh is kept in
memory (cached?), so that multiple copies take almost no extra time to process.

BTW, if you have free time, try the blur code on your castle scene. I would be
curious to know if the castle gets blurred more than your distant background.


Post a reply to this message

From: Bald Eagle
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 19:05:00
Message: <web.6467ff86df2a87151f9dae3025979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> Thanks. It's a lot of fun to play around with. I also *think* that the blur
> effect is distance-based-- that is, objects nearer the mesh camera are blurred
> more than distant objects. I haven't tried a different scene to confirm that,
> although it seems to follow from the fact that the camera's 40 meshes are
> essentially just translated sideways a little bit. Like having 40 'eyes', but
> spread out over a small 'interocular distance' in total. So distant objects
> should have much less blur, just as they would have much less 3-D depth in a
> human stereo view.

Presumably you could render a top-down view, and project very long normal
vectors from each of the triangle centroids out into the scene to get a diagram
of what's going on...

> > [Josh wrote:]
> >
> > These look really good. I'm amazed at how fast it processes multiple
> > rays for each pixel. At least, it seems to me to be pretty fast.
> >
> Same here. The rendering speed might be due to there being only one 'created'
> mesh, which is then used multiple times. I think a triangle mesh is kept in
> memory (cached?), so that multiple copies take almost no extra time to process.

The way I understand it, is that the triangles in the mesh are all stored as the
original mesh object, and all other instantiations are just that mesh with a
matrix transform applied.


How long do these renders take?  I tried a 1024x768 with some code jr has worked
out, and it was taking so long, that I canceled the render and did a tiny one -
which still seemed quite slow.


- BE


Post a reply to this message

From: Kenneth
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 19:50:00
Message: <web.64680b1edf2a87159b4924336e066e29@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
>
> How long do these renders take?  I tried a 1024x768 with some code jr has worked
> out, and it was taking so long, that I canceled the render and did a tiny one -
> which still seemed quite slow.
>

Well, my 8 core/16 thread machine is pretty fast as-is, but...

My 40-mesh blur example, at 800X600 and no AA (and no 'vignetting' or
'distortion'), took a total of 2min 15sec (!)-- of which about 16 sec was the
parse time. Pretty amazing. (I did turn off the radiosity that was in one of the
meshcam includes though.) I guess most of the parse time is spent constructing
the single mesh; it's done in SDL in 'meshcam_macros.inc', not internally. By
saving the mesh on the first go-round, subsequent renders will be even faster--
which makes it easier to experiment with the motion-blur, since the mesh itself
doesn't change.


Post a reply to this message

From: Kenneth
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 20:25:00
Message: <web.64680f63df2a87159b4924336e066e29@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:
>
> For the anaglyph, remember you can also include the mesh AS AN OBJECT in
> the scene itself. Jaime's Vignette code does this. The mesh_camera
> doesn't sit on the mesh, but starts the rays just offset from the mesh.
> So you may be able to include them and tint them ... oh, yeah. I see the
> problem. You can't group real world objects with individual rays in the
> definition. Maybe build the scene in two sets, and two copies of the
> mesh with the tinted overlays for each set (or, at that point, large
> semi transparent spheres around each set would do it).
>
> Just a thought.
>

SO... I've been concentrating on the 'meshcam_persp.demo' scene, and came up
with a way to easily generate a two-'camera' stereo view, at least as the
*basics* of a 3D anaglyph. It's the same set-up as the motion-blur code, but
using  only two 'eyes'. The camera's initial position doesn't actually change;
it's the camera's mesh that is displaced, which has the same effect. Honestly,
I was not *sure* that this trick produced a true 3-D effect, so I had to prove
it to myself with a different test set-up.

(It would seem that the 'meshcam_stereo_demo' scene would be the logical choice
for my experiments, but I have not yet been able to *overlap* the two images
there instead of being side-by-side. My math attempts have been woefully crude
and unsuccessful.)

In the attached image, the center-row renders are the same as in the overlapped
stereogram. If you can cross your eyes, you'll see the nice 3-D effect. My color
anaglyph example had to be made in a separate app though. I hope the 3-D effect
is apparent, as my red-cyan glasses are actually a very dense and
non-standard(?) red/GREEN. I had to fudge the colors somewhat, as well as image
brightness etc.

So far, my attempts to color each of the two views as red/cyan, *within* the
meshcam scene, have all failed. I've tried using the instantiated meshes as
objects...or semi-transparent spheres... or even tiny thin cylinders and discs--
but they interfere with each other in an odd way when used in pairs, and ruin
the effect. For a *single* camera view (only one mesh), an instantiated/colored
mesh works very well-- but not with two views that overlap. As you alluded to,
the mesh-as-CAMERA and the mesh-as-INSTANTIATED-into-the-scene behave completely
differently. That's difficult to visualize and explain though.

Here are some interesting little facts that I've learned along the way:
1) The camera mesh is curved-- like a section of a sphere surface-- and is not
actually at the given 'c_location'; that's the CENTER of the 'sphere'. And the
spherical diameter depends on the given 'c_angle'.

2) When the camera-mesh is first constructed in 'meshcam_macros.inc', it is
apparently made facing +z, and centered on the origin (that is, the 'center of
the sphere' is at the origin, I think). Then it's later re-positioned and
re-oriented by the meshcam_placement macro-- like this in the
'meshcam_persp_demo' file:
                  camera{
                          mesh_camera{ aa_samples+1    0
                          mesh{camera_mesh
                          meshcam_placement(c_location,c_look_at)
                                      }

So, prior to meshcam_placement, the mesh can be moved around (translated) in an
understandable x,y,z way, if you choose to :-)

3) In the 'meshcam_persp_demo' file: When  'aa_samples=0',  only one camera mesh
is created. When it's set to 1, TWO meshes are actually made-- but they exactly
overlap and behave like one mesh. In the equations at
                 #declare c_look_at_tmp=...
it appears that the 2nd mesh should be 'jittered' in its position, but isn't.
I've tried to follow the math there, but I don't yet see why the 2nd one is not
being moved. (If aa_samples=2, the 3rd mesh IS jittered.) HOWEVER, when using
aa_samples=1, the 2nd mesh can be easily exploited to create a stereogram, which
is the method I used.

Anyway, I hope the attached image is self-explanatory.

More to come (!)


Post a reply to this message


Attachments:
Download 'meshcam_stereo_demo_diagram_kw_5_2023.jpg' (187 KB)

Preview of image 'meshcam_stereo_demo_diagram_kw_5_2023.jpg'
meshcam_stereo_demo_diagram_kw_5_2023.jpg


 

From: Josh English
Subject: Re: Playing with the mesh camera
Date: 19 May 2023 23:28:36
Message: <64683e64@news.povray.org>
On 5/19/2023 3:14 PM, Kenneth wrote:
> Thanks. It's a lot of fun to play around with. I also*think*  that the blur
> effect is distance-based-- that is, objects nearer the mesh camera are blurred
> more than distant objects. I haven't tried a different scene to confirm that,
> although it seems to follow from the fact that the camera's 40 meshes are
> essentially just translated sideways a little bit. Like having 40 'eyes', but
> spread out over a small 'interocular distance' in total. So distant objects
> should have much less blur, just as they would have much less 3-D depth in a
> human stereo view.

It depends on where you center the transformation. If you rotate the 
meshes around the look_at point you get focal blur.

I suspect based on my Towers scene moving the meshes based on the camera 
location you get less blurring in the distance. It makes sense because 
the angles created by two triangles in a mesh to a distance object is 
much smaller than the angle on a closer object.

Josh


Post a reply to this message


Attachments:
Download 'meshcam07c.png' (203 KB)

Preview of image 'meshcam07c.png'
meshcam07c.png


 

From: Josh English
Subject: Re: Playing with the mesh camera
Date: 20 May 2023 00:18:31
Message: <64684a17$1@news.povray.org>
On 5/19/2023 5:21 PM, Kenneth wrote:

> 
> SO... I've been concentrating on the 'meshcam_persp.demo' scene, and came up
> with a way to easily generate a two-'camera' stereo view, at least as the
> *basics* of a 3D anaglyph. It's the same set-up as the motion-blur code, but
> using  only two 'eyes'. The camera's initial position doesn't actually change;
> it's the camera's mesh that is displaced, which has the same effect. Honestly,
> I was not *sure* that this trick produced a true 3-D effect, so I had to prove
> it to myself with a different test set-up.
> 
> (It would seem that the 'meshcam_stereo_demo' scene would be the logical choice
> for my experiments, but I have not yet been able to *overlap* the two images
> there instead of being side-by-side. My math attempts have been woefully crude
> and unsuccessful.)

I think that demo is designed for things like Google Cardboard.


> So far, my attempts to color each of the two views as red/cyan, *within* the
> meshcam scene, have all failed. I've tried using the instantiated meshes as
> objects...or semi-transparent spheres... or even tiny thin cylinders and discs--
> but they interfere with each other in an odd way when used in pairs, and ruin
> the effect. For a *single* camera view (only one mesh), an instantiated/colored
> mesh works very well-- but not with two views that overlap. As you alluded to,
> the mesh-as-CAMERA and the mesh-as-INSTANTIATED-into-the-scene behave completely
> differently. That's difficult to visualize and explain though.

Oddly enough, you can give the mesh a pigment:

camera {
   mesh_camera { 2 0
     mesh { spherical_mesh pigment { blue 1 transmit 0.1 }
       transform { Position_on_Camera(Camera_Location, Camera_Look_At, 
Camera_Sky) }
     }
     mesh { perspective_mesh pigment { red 1 transmit 0.1 }

     }
   }

and the thing renders without color. I would expect this to raise a 
parsing error but it just ignores it. It's a shame, because this could 
really help with these sorts of effects.
> 
> Here are some interesting little facts that I've learned along the way:
> 1) The camera mesh is curved-- like a section of a sphere surface-- and is not
> actually at the given 'c_location'; that's the CENTER of the 'sphere'. And the
> spherical diameter depends on the given 'c_angle'.

Yes. It's a proper pinhole, not like the standard perspective camera.
> 
> 2) When the camera-mesh is first constructed in 'meshcam_macros.inc', it is
> apparently made facing +z, and centered on the origin (that is, the 'center of
> the sphere' is at the origin, I think). Then it's later re-positioned and
> re-oriented by the meshcam_placement macro-- like this in the
> 'meshcam_persp_demo' file:
>                    camera{
>                            mesh_camera{ aa_samples+1    0
>                            mesh{camera_mesh
>                            meshcam_placement(c_location,c_look_at)
>                                        }
> 
> So, prior to meshcam_placement, the mesh can be moved around (translated) in an
> understandable x,y,z way, if you choose to :-)

Fun, ain't it? This is the easiest way to do it, in my opinion. There's 
less math. At least, there's easier ways to sequester the math in a macro.

> 
> More to come (!)
> 

I'm looking forward to it. You're faster than I am.

Josh


Post a reply to this message

From: jr
Subject: Re: Playing with the mesh camera
Date: 20 May 2023 08:30:00
Message: <web.6468bc7ddf2a8715b49d80446cde94f1@news.povray.org>
hi,

Josh English <Jos### [at] joshuarenglishcom> wrote:
> On 5/19/2023 5:21 PM, Kenneth wrote:
> ...
> >
> > More to come (!)
> >
>
> I'm looking forward to it. You're faster than I am.

+1.

(this thread is "shaping up nicely" :-))


regards, jr.


Post a reply to this message

<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.