I am trying to render 3D volume,raw data is successfully uploaded from main memory to graphics memory but still there is nothing on screen.here is my shader code can someone help me to locate the issue.
const char vShaderStr[] =
"#version 300 es \n"
"in vec3 av4position; \n"
"uniform mat4 u_mvpMatrix; \n"
"smooth out vec3 uVU; \n"
"void main() \n"
"{ \n"
"gl_Position=u_mvpMatrix*vec4(av4position.xyz,1);\n"
"uVU=av4position+vec3(0.5); \n"
"} \n";
const char fShaderStr[] =
"#version 300 es \n"
"precision mediump float; \n"
"layout(location=0) out vec4 vFragColor; \n"
"smooth in vec3 uVU;
\n"
"uniform sampler3D volume; \n"
"uniform vec3 camPos; \n"
"uniform vec3 step_size; \n"
"const int MAX_SAMPLES=300; \n"
"const vec3 texMin=vec3(0); \n"
"const vec3 texMax=vec3(1); \n"
"void main() \n"
"{ \n"
"vec3 dataPos=uVU; \n"
"vec3 geomDir=normalize((uVU-vec3(0.5))-camPos); \n"
"vec3 dirStep=geomDir*step_size; \n"
"bool stop=false; \n"
"for(int i=0;i<MAX_SAMPLES;i++) \n"
"{ \n"
"dataPos=dataPos+dirStep; \n"
"stop = dot(sign(dataPos-texMin),sign(texMax-dataPos)) < 3.0; \n"
"if (stop) \n"
"break; \n"
"float sample = texture(volume, dataPos).r; \n"
"float prev_alpha = sample - (sample * vFragColor.a); \n"
"vFragColor.rgb = prev_alpha * vec3(sample) + vFragColor.rgb;\n"
"vFragColor.a += prev_alpha; \n"
"if( vFragColor.a>0.99) \n"
"break; \n"
" } \n"
// "vFragColor = vec4(1, 0, 0, 1); \n"
"}