Comments (6)
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.
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.
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.
There's no good reason why
Texture.store
doesn't work forT_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.
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.
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)
- Implement relative mouse mode emulation using cursor centering HOT 1
- Add FuncReverse() to the Interval system
- Interval: `LerpFunctionInterval()` returns `toData` when played backwards and duration is 0.0
- RPM package generation fails
- Implement SteamAudio SDK HOT 9
- Font.setOutline does not work entirely correctly HOT 2
- how to use LerpFunctionInterval and functools.partial not working HOT 2
- finalize_distribution_options entry point requires panda3d import
- TransformStat::get_mat() returns singular matrix on macOS HOT 5
- font.setPixelsPerUnit crashes when values get too high HOT 3
- identical condition HOT 1
- return twice
- unclear error with possibly non BMP character HOT 3
- Standardize TypedWritable HOT 2
- PGEntry getCursorY fails on word-wrapped or multiline text HOT 2
- Grammar railroad diagram HOT 5
- 2 small Preprocessor bugs HOT 11
- Reimplement core functionality of DIRECT in C++ codebase HOT 1
- Cppparser preprocessor do not expand macros with arguments correctly HOT 94
- bam_model_extensions changes external path references in distributions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panda3d.