I was trying to recover depth info for raycasting, but when I tried to print the value gl_FragCoord.z inside RenderProgram.ts (as color output), its value is always 0.5.
Are there any solution for this kind of need? Many thanks.
Steps to reproduce:
turn on depth test with gl.enable(gl.DEPTH_TEST); at this line
insert the following in front of the fragment's main shader
I was trying to recover depth info for raycasting, but when I tried to print the value
gl_FragCoord.z
insideRenderProgram.ts
(as color output), its value is always 0.5.Are there any solution for this kind of need? Many thanks.
Steps to reproduce:
gl.enable(gl.DEPTH_TEST);
at this lineI am wondering why is the value of
gl_FragCoord.z
always 0.5? And is there any other way to recover depth of fragment without this value?