Coder Social home page Coder Social logo

Visualize depth buffer about sokol HOT 2 CLOSED

floooh avatar floooh commented on July 3, 2024
Visualize depth buffer

from sokol.

Comments (2)

floooh avatar floooh commented on July 3, 2024

Using a depth image object as texture won't work unfortunately (and it should warn about this in the validation layer, looks like I forgot a check).

The reason (at least for GL) is that a sokol image with depth-pixelformat is created as a glRenderBuffer object (see here:

sokol/sokol_gfx.h

Line 2738 in ce6414d

/* special case depth-stencil-buffer? */
)

IFIR the reason for this was various compatibility problems with GLES2 platforms (unextended GLES2 and WebGL doesn't have depth textures)/

If you need the depth texture visualization only for debugging purposes I'd recommend using a 3D API debugger like RenderDoc. If you need the depth content otherwise one solution would be to render the depth into a image texture from the pixel shader (but if you need to run on lowend platforms, also keep in mind that single-channel float32 textures might not be available everywhere, for the shadow map in this demo: http://floooh.github.io/oryol-samples/wasm/BulletPhysicsBasic.html I used the RGBA8 encoding from this blog post: http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/

Cheers,
-Floh.

from sokol.

dbacchet avatar dbacchet commented on July 3, 2024

thanks for the explanation @floooh!

I will try copying the depth buffer into a texture; that should work for me (only targeting desktop systems).

closing this issue.

from sokol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.