Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create simple API to give users access to depth buffer #4090

Closed
mvaligursky opened this issue Mar 8, 2022 · 0 comments · Fixed by #4244
Closed

Create simple API to give users access to depth buffer #4090

mvaligursky opened this issue Mar 8, 2022 · 0 comments · Fixed by #4244
Assignees
Labels
area: examples area: graphics Graphics related issue good first issue Good for newcomers

Comments

@mvaligursky
Copy link
Contributor

mvaligursky commented Mar 8, 2022

At the moment, the engine by default creates a Depth layer, which is disabled. If this layer is added to a camera, and the layer is enabled, this triggers the rendering operation (render on webgl1, copying of depth buffer on webgl2) at the point the camera gets to render the Depth layer. After this point, the depth texture is accessible to following layers.

The way to enable the depth layer is this:

        const depthLayer = this.app.scene.layers.getLayerById(LAYERID_DEPTH);
        depthLayer.incrementCounter();

and to disable:

        depthLayer.decrementCounter();

We should expose a simple API to manage this, perhaps

CameraComponent.renderDepth = true;

Perhaps some changes could be made to how the Depth layer is integrated into the camera. By default, the layer is automatically added to the default camera. And the user is responsible for adding it to other cameras (when rendering to texture). Perhaps the renderDepth API could automatically add / remove the layer for the camera as well.

It'd be also great to create an engine example showing how to use the rendered depth in some custom shader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: examples area: graphics Graphics related issue good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant