bjornblissing / osgoculusviewer

An OsgViewer with support for the Oculus Rift
Other
106 stars 67 forks source link

How can I enable stencil functionality? #109

Open keugbang opened 3 years ago

keugbang commented 3 years ago

Hello, I was wondering how to enable the stencil functionality. I simply thought that modifying OculusDevice::createRTTCamera would make it work but failed.

What I did was to add stencil buffer bit to the camera clear mask, and replace depth buffer attachment with the following statement: camera->attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, GL_DEPTH_STENCIL_EXT);

bjornblissing commented 3 years ago

I am a bit unsure of what you are trying to achieve. However, the Oculus SDK uses the depth buffer for Asynchronous Spacewarp calculations, so modifications of the depth buffer might have unexpected consequences.

keugbang commented 3 years ago

Could there be a way to add stencil buffer in addition to the existing depth buffer? Please forgive me. I may be asking a silly question since my knowledge in OSG and Oculus is limited. I am trying to implement a Head Up Display where symbols are projected onto the transparent mirror. I was able to achieve this before with general(?) OSG viewer setup and now I am trying to make it work with the Oculus.

bjornblissing commented 3 years ago

The Oculus SDK have a functionality called layers. There exists a separate layer type called Quad which should be used for HeadUpDisplays and similar head locked graphics: https://developer.oculus.com/documentation/native/pc/dg-render/#layers

keugbang commented 3 years ago

I am sorry that I didn’t explain in detail. What I meant by Head Up Display was a 3D model of a HUD in a fighter aircraft where information is projected on to the transparent mirror in front of the cockpit. The ‘quad’ layer of Oculus SDK looks like a 2D screen-fixed overlay.