Skip to content

How to get depth from GPU #2035

Answered by raysan5
copark86 asked this question in Q&A
Oct 6, 2021 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

@copark86 I'm afraid this is out-of-scope for raylib, it's a specific use-case. Still, it can be accomplished rendering the depth buffer using a shader and getting it. Here there is an issue explaining the process: #1872

A brief summary:

  1. Use a RenderTexture with a depth Texture instead of RenderBuffer (you need to change LoadRenderTexture() function or use rlgl directly for that)
  2. Render your world
  3. Render RenderTexture.depth using a Shader to linearize the depth values of that texture.
  4. LoadImageFromScreen() should return the drawn depth texture linearized currently on the screen framebuffer

There is probably a simpler way to do that but not exposed by raylib, you should use OpenGL direct…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@copark86
Comment options

@TextBox75
Comment options

Answer selected by copark86
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants