Welcome aboard!
In WebGL, Texture.readPixels
always return RGBA data. So, you should either use CreateRGBATexture
instead of CreateRTexture
of create a new buffer from depth_arr
that will only contain the r component.
- first case: https://playground.babylonjs.com/#1PHYB0#140
- second case: https://playground.babylonjs.com/#1PHYB0#141
You can call doit()
in the console of the browser to create the texture and see it in the inspector.