Can depth pixel numbers be extracted from THREE.WebGLRenderer
, similar to the .readRenderTargetPixels
functionality? Basically, is there an update to this question. My starting point is Three.js r80. Normalized values are fine if I can also convert to distances.
Related methods:
I see that WebGL's
gl.readPixels
does not supportgl.DEPTH_COMPONENT
like OpenGL's.glReadPixels
does.THREE.WebGLRenderTarget
does support a.depthTexture
viaTHREE.WebGLRenderer
'sWEBGL_depth_texture
extension. AlthoughTHREE.DepthTexture
does not contain.image.data
likeTHREE.DataTexture
does.I also see that
THREE.WebGLShadowMap
uses.renderBufferDirect
with aTHREE.MeshDepthMaterial
.
Data types:
- A non-rendered canvas, can use
.getContext('2d')
with.getImageData(x,y,w,h).data
for the topToBottom pixels as aUint8ClampedArray
. - For a rendered canvas,
render()
usesgetContext('webgl')
and contexts may only be queried once, sogetImageData
cannot be used. - Instead render to a target and use
.readRenderTargetPixels(...myArrToCopyInto...)
to access (copy out) the bottomToTop pixels in yourUint8Array
. - Any canvas can use
.toDataURL("image/png")
to return aString
in the pattern"data:image/png;base64,theBase64PixelData"
.