Camera projection

Use this forum for general user support and related questions.
Forum rules
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
User avatar
TAO
Developer
Posts: 753
Joined: Sun Mar 24, 2019 4:49 pm
Location: France
Contact:

Re: Camera projection

Post by TAO » Sun Jul 18, 2021 2:44 pm

Dade wrote:
Sun Jul 18, 2021 11:01 am
It looks to me more as a modeller tool than a renderer one but it should easy to add anyway.
it would be great to have it.
Omid Ghotbi (TAO)
Last update information
https://forums.luxcorerender.org/viewto ... 590#p30154

User avatar
Dade
Developer
Posts: 5523
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Camera projection

Post by Dade » Thu Jul 22, 2021 9:57 am

I added the support for camera projection UV shape. The UV of a mesh can be computed with the following syntax:

Code: Select all

scene.shapes.obj_shell_src.type = mesh
scene.shapes.obj_shell_src.ply = scenes/luxball/luxball-shell.ply
##
scene.shapes.obj_shell.type = cameraprojuv
scene.shapes.obj_shell.source = obj_shell_src
scene.shapes.obj_shell.uvindex = 0
This is a normal UV rendering:

i1.jpg

And this is a mera projection UV rendering:

i2.jpg

Note: the UVs are (pre-)computed at vertices so UV interpolation is done in screen space and not in world space. This means large triangles can introduce texture image deformation.
Support LuxCoreRender project with salts and bounties

User avatar
TAO
Developer
Posts: 753
Joined: Sun Mar 24, 2019 4:49 pm
Location: France
Contact:

Re: Camera projection

Post by TAO » Thu Jul 22, 2021 10:26 am

Dade wrote:
Thu Jul 22, 2021 9:57 am
I added the support for camera projection UV shape. The UV of a mesh can be computed with the following syntax:

Code: Select all

scene.shapes.obj_shell_src.type = mesh
scene.shapes.obj_shell_src.ply = scenes/luxball/luxball-shell.ply
##
scene.shapes.obj_shell.type = cameraprojuv
scene.shapes.obj_shell.source = obj_shell_src
scene.shapes.obj_shell.uvindex = 0
This is a normal UV rendering:


i1.jpg


And this is a mera projection UV rendering:


i2.jpg


Note: the UVs are (pre-)computed at vertices so UV interpolation is done in screen space and not in world space. This means large triangles can introduce texture image deformation.
Amazing, I'll give it a try tonight.
Omid Ghotbi (TAO)
Last update information
https://forums.luxcorerender.org/viewto ... 590#p30154

User avatar
TAO
Developer
Posts: 753
Joined: Sun Mar 24, 2019 4:49 pm
Location: France
Contact:

Re: Camera projection

Post by TAO » Sat Jul 24, 2021 10:24 am

Dade wrote:
Thu Jul 22, 2021 9:57 am
I added the support for camera projection UV shape. The UV of a mesh can be computed with the following syntax:

Code: Select all

scene.shapes.obj_shell_src.type = mesh
scene.shapes.obj_shell_src.ply = scenes/luxball/luxball-shell.ply
##
scene.shapes.obj_shell.type = cameraprojuv
scene.shapes.obj_shell.source = obj_shell_src
scene.shapes.obj_shell.uvindex = 0
This is a normal UV rendering:


i1.jpg


And this is a mera projection UV rendering:


i2.jpg


Note: the UVs are (pre-)computed at vertices so UV interpolation is done in screen space and not in world space. This means large triangles can introduce texture image deformation.
I test it and it is working as it is supposed to, just one thing that I do not know how to implement is how to use one camera as camera projection and render the image through another camera.
Let say we have two cameras, Cam1 that should be used as a camera projection map as the first camera and Cam2 that I want to use as actual render view.
Omid Ghotbi (TAO)
Last update information
https://forums.luxcorerender.org/viewto ... 590#p30154

bestman8
Posts: 16
Joined: Sat Jul 25, 2020 6:45 pm

Re: Camera projection

Post by bestman8 » Sat Jul 24, 2021 1:23 pm

TAO wrote:
Sat Jul 24, 2021 10:24 am
Dade wrote:
Thu Jul 22, 2021 9:57 am
I added the support for camera projection UV shape. The UV of a mesh can be computed with the following syntax:

Code: Select all

scene.shapes.obj_shell_src.type = mesh
scene.shapes.obj_shell_src.ply = scenes/luxball/luxball-shell.ply
##
scene.shapes.obj_shell.type = cameraprojuv
scene.shapes.obj_shell.source = obj_shell_src
scene.shapes.obj_shell.uvindex = 0
This is a normal UV rendering:


i1.jpg


And this is a mera projection UV rendering:


i2.jpg


Note: the UVs are (pre-)computed at vertices so UV interpolation is done in screen space and not in world space. This means large triangles can introduce texture image deformation.
I test it and it is working as it is supposed to, just one thing that I do not know how to implement is how to use one camera as camera projection and render the image through another camera.
Let say we have two cameras, Cam1 that should be used as a camera projection map as the first camera and Cam2 that I want to use as actual render view.
if there are more cameras maybe ask the user what camera should be used at about the same place where the setting is and the default is just the camera that is used

User avatar
Dade
Developer
Posts: 5523
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Camera projection

Post by Dade » Sat Jul 24, 2021 2:31 pm

TAO wrote:
Sat Jul 24, 2021 10:24 am
Let say we have two cameras, Cam1 that should be used as a camera projection map as the first camera and Cam2 that I want to use as actual render view.
There is only one single camera currently in LuxCore. The need of multiple camera definitions has never come up until now.
Support LuxCoreRender project with salts and bounties

User avatar
B.Y.O.B.
Developer
Posts: 4124
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Camera projection

Post by B.Y.O.B. » Sat Jul 24, 2021 4:03 pm

TAO wrote:
Sat Jul 24, 2021 10:24 am
Let say we have two cameras, Cam1 that should be used as a camera projection map as the first camera and Cam2 that I want to use as actual render view.
That's no longer a camera projection though.
It's more a rotated planar projection (if we assume Cam1 is an orthographic camera).

By the way it's not clear to me why this needs to be implemented as a shape. Cycles does this stuff without baking it into the mesh vertices.

User avatar
TAO
Developer
Posts: 753
Joined: Sun Mar 24, 2019 4:49 pm
Location: France
Contact:

Re: Camera projection

Post by TAO » Sat Jul 24, 2021 4:11 pm

B.Y.O.B. wrote:
Sat Jul 24, 2021 4:03 pm
TAO wrote:
Sat Jul 24, 2021 10:24 am
Let say we have two cameras, Cam1 that should be used as a camera projection map as the first camera and Cam2 that I want to use as actual render view.
That's no longer a camera projection though.
It's more a rotated planar projection (if we assume Cam1 is an orthographic camera).

By the way it's not clear to me why this needs to be implemented as a shape. Cycles does this stuff without baking it into the mesh vertices.
In 3dsmax and maya it bakes in mesh UV through modifier same as Dade describe it and of course can be remove from modifier stack in anytime, so it can be used directlly like normal UV.
But any other solution can work here, as far as at least one camera can be used for projection map and the others for render view.
Omid Ghotbi (TAO)
Last update information
https://forums.luxcorerender.org/viewto ... 590#p30154

User avatar
Dade
Developer
Posts: 5523
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Camera projection

Post by Dade » Sat Jul 24, 2021 8:20 pm

B.Y.O.B. wrote:
Sat Jul 24, 2021 4:03 pm
That's no longer a camera projection though.
It's more a rotated planar projection (if we assume Cam1 is an orthographic camera).

By the way it's not clear to me why this needs to be implemented as a shape. Cycles does this stuff without baking it into the mesh vertices.
Bake has no rendering cost: back projecting the point for each ray intersection with such material/texture is far more expansive. The draw back is the one I explained in my note.

BTW, actually, it is possible to use multiple cameras: you create the object with Cam1, than edit the scene to redefine the camera as Cam2 and you will obtain the desired result. The object is backed with Cam1 but the rendering will use Cam2.
Support LuxCoreRender project with salts and bounties

User avatar
TAO
Developer
Posts: 753
Joined: Sun Mar 24, 2019 4:49 pm
Location: France
Contact:

Re: Camera projection

Post by TAO » Sun Jul 25, 2021 6:15 am

Dade wrote:
Sat Jul 24, 2021 8:20 pm
B.Y.O.B. wrote:
Sat Jul 24, 2021 4:03 pm
That's no longer a camera projection though.
It's more a rotated planar projection (if we assume Cam1 is an orthographic camera).

By the way it's not clear to me why this needs to be implemented as a shape. Cycles does this stuff without baking it into the mesh vertices.
Bake has no rendering cost: back projecting the point for each ray intersection with such material/texture is far more expansive. The draw back is the one I explained in my note.

BTW, actually, it is possible to use multiple cameras: you create the object with Cam1, than edit the scene to redefine the camera as Cam2 and you will obtain the desired result. The object is backed with Cam1 but the rendering will use Cam2.
Updating a scene is one solution, but i think having support for multiple camera at leat 2 camera is far more better solution, imagine that camera projection moving through the time, for each frame scene should be translate and again update after that to be able to render correctlly.
Also having multiple camera is good for multi camera render session too, so we can have as many camera as we want and a flag to decide which one need to be render, so it will be no need for sending another scene to render qeue and just simplly change the camera flag. of course this is a different feature but it can be considered if multiple camera feature is avilable.
Omid Ghotbi (TAO)
Last update information
https://forums.luxcorerender.org/viewto ... 590#p30154

Post Reply