Giter VIP home page Giter VIP logo

Comments (6)

rdb avatar rdb commented on May 30, 2024

Thanks, this is fixed now, I believe. The format-choosing code had been changed to set the format to F_depth_component24, but the copy-to-RAM code in the GL code didn't understand what component type to use for F_depth_component24.

from panda3d.

Epihaius avatar Epihaius commented on May 30, 2024

Thank you!
The code snippet works again now, but I have to set the number of depth bits to 16; when it is set to 24, the depth values are all zero (when checking the pixel color of the PNMImage I store the depth texture into).

Consider the following code:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase

loadPrcFileData("", "depth-bits 24")


class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)

        depth_tex = Texture("depth_texture")
        depth_tex.set_format(Texture.F_depth_component)
        fbp = FrameBufferProperties()
        fbp.set_depth_bits(24)
        buffer = self.win.make_texture_buffer("buffer", 1, 1, depth_tex, to_ram=True, fbp=fbp)
        self.graphicsEngine.render_frame()
        img = PNMImage(1, 1)
        depth_tex.store(img)
        pixel = img.get_xel(0, 0)
        print("Pixel:", pixel)


app = MyApp()
app.run()

The output is:

Pixel: LVecBase3f(0, 0, 0)

but when I do fbp.set_depth_bits(16) I get the expected result:

Pixel: LVecBase3f(0, 0, 1)

from panda3d.

rdb avatar rdb commented on May 30, 2024

That's because PNMImage only supports up to 16 bits per component, and the current code downloads 24-bit-depth buffers into the 32-bit T_unsigned_int component type.

There's no good reason why Texture.store doesn't work for T_unsigned_int textures. I will check in a fix for that shortly. However, do you remember what component_type the data was for your code in 1.9?

from panda3d.

Epihaius avatar Epihaius commented on May 30, 2024

There's no good reason why Texture.store doesn't work for T_unsigned_int textures. I will check in a fix for that shortly.

Much appreciated!

However, do you remember what component_type the data was for your code in 1.9?

Yes, that was T_float.

On a related note, it seems that the TexturePeeker class isn't compatible with depth textures; would it be worth it to fix this (if that's even possible), in case it gave a better performance when continually checking pixel values, compared to storing the texture in a PNMImage every frame?
If you find it worthwile, I would be willing to file a new issue report for this.

P.S. (Off-topic) In case you missed it, I commented on issue #189 some time ago.

from panda3d.

rdb avatar rdb commented on May 30, 2024

OK, now 24-bit depth is converted to T_float again (e4e24ee). Also, TexturePeeker now supports both unsigned integer and floating-point textures (348b1c3). And store() is now implemented for T_unsigned_int (9dcfcbf).

Indeed, TexturePeeker is a faster way to access texture data. In fact, if you try to store a floating-point texture into a PNMImage, it will first store it into a PfmFile (the floating-point equivalent for PNMImage) and convert that into a PNMImage, so it is extra redundant. TexturePeeker is even faster because it does no extra copy or conversion at all.

I did not forget about #189, I will look into that when I find some time.

from panda3d.

Epihaius avatar Epihaius commented on May 30, 2024

Thank you very much for all those fixes and improvements! Just tested my code snippet again and everything works fine now.

Good to know about the efficiency of TexturePeeker; thanks again for extending its usefulness!

from panda3d.

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.