PDA

View Full Version : help needed with raycasting



abhishek bansal
11-29-2010, 11:24 AM
hii all,

i am struggling with raycasting algorithm for past few days .... my program is showing output as attached in files..
my ray casting shader is as follows..


uniform sampler3D volumeData;
uniform sampler1D transferFunction;
varying vec3 texCoord;
uniform vec3 xCameraPosition;
uniform vec3 bboxMin;
uniform vec3 bboxMax;
uniform float step;
uniform int steps;
uniform vec3 bgColor;

void main(void)
{
vec3 rayOrigin = texCoord;
vec3 rayDir = normalize(rayOrigin - xCameraPosition);
vec3 position = rayOrigin;
vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0);
vec3 zarroVector = vec3(0, 0, 0);
for (int i = 0; i < steps; ++i)
{
position += step * rayDir;
if (any(greaterThan(position, bboxMax)) || any(lessThan(position, bboxMin)))
{
break;
}
float density = texture3D(volumeData, position).r;
vec4 color = texture1D(transferFunction, density);

finalColor += vec4(color.rgb * (1.0 - color.a) * step, color.a);

if (finalColor.a > .99)
{
break;
}
}

gl_FragColor = vec4(finalColor.rgb * finalColor.a + (1.0 - finalColor.a) * bgColor, 1.0);
}


i have checked my code many times and everything seems ok to me...can anyone please look at the output and suggest me what may be the problem is ..?? i m really exhausted..its very important for my final year major project...plzz help..

thank you

edit: if u need any code from my c++ program please ask...nd i am using Ati radeon 5470 which supports opengl 3.2 and shader model 3

abhishek bansal
11-30-2010, 10:07 AM
ok here my complete c++ source code.....!!