[osg-users] Cameras with same target and different near/far
Riccardo Corsi
riccardo.corsi at kairos3d.it
Tue Oct 20 05:58:19 PDT 2015
Hi all,
sorry to revamp again my own thread, I'd just like to understand if there's
something I'm missing or if the issue I'm facing is an expected behavior.
So simplify even further my question, I sum it up as follows:
I want to render a scene from within a car. I want to use 2 different
cameras, one for the outside world, and one for the car internals, to
optimize near/far ratio for each of them.
I attach the outside scene under the main camera.
Then I have a camera setup as follows to render the car internals.
osg::Camera* carCam = new osg::Camera;
// draw subgraph after main camera
carCam->setRenderOrder(osg::Camera::POST_RENDER, 1);
// clear depth only
carCam->setClearMask(GL_DEPTH_BUFFER_BIT);
// force near/far values for the car camera
carCam->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
carCam->setProjectionMatrixAsPerspective(fov, ar, 0.1, 10);
// render the user vehicle
carCam->addChild(carInternalModel);
Now:
- if I add the car camera as viewer's slave, everything works as expected,
near/far is fixed and independent from the main camera
- if I place the car camera in scene, cull settings are overwritten, and
near/far is inherited from the main camera no matter what
Is this the expected behavior?
Thank you,
Ricky
On Mon, Sep 14, 2015 at 11:37 AM, Riccardo Corsi <riccardo.corsi at kairos3d.it
> wrote:
> Hi all,
>
> sorry to revamp my own thread, but I'm facing again the same problem I
> explained in the first post and couldn't find a correct setup.
> Any hint?
> thanks,
> ricky
>
>
>
> On Fri, Jul 10, 2015 at 5:46 PM, Riccardo Corsi <
> riccardo.corsi at kairos3d.it> wrote:
>
>> Hi all,
>>
>> what I'm after is a sort of simple depth peeling, the aim is to render 2
>> different parts of a whole scene with different near/far settings to the
>> same render target. Something like:
>>
>> * mainCamera (render the huge surrounding scene)
>> |
>> |-- huge scene
>> |
>> |-- detailCamera (render a closer object in detail with small z near/far)
>> |
>> |-- detailed geometry
>>
>>
>> I thought the best option was to place the detailCamera in scene, to
>> share the render target, and:
>> - set a custom near/far settings
>> - set the clear depth bit
>> - set the render order to post (or nested?)
>> but I couldn't get it to work.
>>
>> I'm particular I have some doubts:
>> 1. does a PRE/POST and a NESTED ORDER camera have the same behavior with
>> respect to sharing the mainCamera render target, when placed in-scene under
>> it?
>> 2. for point 1, does anything change if mainCamera renders to the Frame
>> Buffer or to and FBO?
>> 3. is there any other/more correct way to get 2 cameras to render to the
>> same FBO with different near/far settings?
>>
>> Thank you!
>> Ricky
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151020/7b6136f6/attachment-0002.htm>
More information about the osg-users
mailing list