PDA

View Full Version : Volume Rendering Artifacts



vincent911001
04-05-2015, 08:27 PM
Hi all,

I have encountered some rendering artifacts in volume rendering as below:

1720 1721

A you probably notice it, there is black halo at the edge of the rendered image when view from certain angle.
FYI, code snippet of main function of fragment shader is as below(retrived from OpenGL Development Cookbook):

void main()
{
//get the 3D texture coordinates for lookup into the volume dataset
vec3 dataPos = vUV;

vec3 geomDir = normalize((vec3(0.556,0.614,0.201)*vUV-vec3(0.278,0.307,0.1005)) - camPos);

vec3 dirStep = geomDir * step_size;

//flag to indicate if the raymarch loop should terminate
bool stop = false;

//for all samples along the ray
for (int i = 0; i < MAX_SAMPLES; i++) {
// advance ray by dirstep
dataPos = dataPos + dirStep;

stop = dot(sign(dataPos-texMin),sign(texMax-dataPos)) < 3.0f;

//if the stopping condition is true we brek out of the ray marching loop
if (stop)
break;

// data fetching from the red channel of volume texture
float sample = texture(volume, dataPos).r;


float prev_alpha = sample - (sample * vFragColor.a);
vFragColor.rgb = (prev_alpha) * vec3(sample) + vFragColor.rgb;
vFragColor.a += prev_alpha;


if( vFragColor.a>0.99)
break;
}

FYI, the volume data is not similar in dimension, thus, some operation is done to make sure the coordinates do maps to the texture coordinates.

(vec3(0.556,0.614,0.201)*vUV-vec3(0.278,0.307,0.1005)
So, what probably could result in this artifacts???:dejection::dejection:

vincent911001
04-05-2015, 10:22 PM
FYI, the artifacts appear when viewing at the edge of the cuboid.....

vincent911001
04-07-2015, 06:44 PM
FYI, the artifacts appear when viewing at the edge of the cuboid.....

The problem is solved by changing the interpolation parameter of mipmapping to GL_LINEAR from GL_LINEAR_MIPMAP_LINEAR.....