opengl es - Depth Map is white - webgl -


i using shaders draw depth map in image. here shader code :

vertex shader:

void main(void) {         gl_pointsize = apointsize;         gl_position = upmatrix * umvmatrix * vec4(avertexposition, 1.0);         vcolor = avertexcolor;         visdepth = aisdepth;         vhastexture = ahastexture;         if (ahastexture > 0.5)             vtexturecoord = atexturecoord;      } 

fragement shader:

void main(void) {         if (vhastexture < 0.5 && visdepth < 0.5)             gl_fragcolor = vcolor;          if (vhastexture > 0.5) {                  vec4 texturecolor = texture2d(utexture, vec2(vtexturecoord.s, vtexturecoord.t));             gl_fragcolor = vec4(texturecolor.rgb, texturecolor.a * utexturealpha);         }         if (visdepth > 0.5){              float ndcdepth = (2.0 * gl_fragcoord.z - gl_depthrange.near - gl_depthrange.far) /                             (gl_depthrange.far - gl_depthrange.near);             float clipdepth = ndcdepth /gl_fragcoord.w;              gl_fragcolor = vec4((clipdepth*0.5)+0.5);         }        } 

i used following link reference calculations : draw depth value in opengl using shaders

i getting values white shown below:

enter image description here

enter image description here

from 2 images above, seen points far right of image behind. not reflected in image downloaded. after using drawarrays function, use todataurl function download canvas data. images result of download. know of possible reasons this?

for seeks answer question , here's little hint :
if want view depth map , have linearize it...

float linearize_z(float depth , float znear , float zfar){  return (2*znear ) / (zfar + znear - depth*(zfar -znear)) ; } 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -