Glsl 体绘制光线投射瑕疵

Glsl 体绘制光线投射瑕疵,glsl,webgl,raycasting,volume-rendering,Glsl,Webgl,Raycasting,Volume Rendering,我正在尝试在WebGL中实现一个简单的光线投射体渲染 这是一种工作方式,但在旋转体积时会出现一些瑕疵(即头部出现变形) 现场演示: 用于调试的GLSL代码: 代码的简化版本: for(int rayStep = 0; rayStep < maxSteps; rayStep++){ // map world coordinates to data coordinates vec4 dataCoordinatesRaw = uWorldToData * currentPosit

我正在尝试在WebGL中实现一个简单的光线投射体渲染

这是一种工作方式,但在旋转体积时会出现一些瑕疵(即头部出现变形)

现场演示:

用于调试的GLSL代码:

代码的简化版本:

for(int rayStep = 0; rayStep < maxSteps; rayStep++){

  // map world coordinates to data coordinates
  vec4 dataCoordinatesRaw = uWorldToData * currentPosition;
  ivec3 dataCoordinates = ivec3(int(floor(dataCoordinatesRaw.x)), int(floor(dataCoordinatesRaw.y)), int(floor(dataCoordinatesRaw.z)));

  float intensity = getIntensity(dataCoordinates);

  // we have the intensity now
  vec3 colorSample = vec3(intensity);
  float alphaSample = intensity;

  accumulatedColor += (1.0 - accumulatedAlpha) * colorSample * alphaSample;
  accumulatedAlpha += alphaSample;

  //Advance the ray.
  currentPosition += deltaDirection;
  accumulatedLength += deltaDirectionLength;

  if(accumulatedLength >= rayLength || accumulatedAlpha >= 1.0 ) break;
}
for(int rayStep=0;rayStep=光线长度| |累计阿尔法>=1.0)中断;
}
我不明白是什么可以解释这些人工制品

可能是因为我不使用渐变来调节不透明度/颜色吗


任何提示都是非常受欢迎的。

在光线投射的第一次过程中,未正确计算背面坐标。“标准化”坐标的范围不是[0,1]。它是[-.5,1.5],因此当[0,1]范围之外的所有值都被钳制时,会创建可视化伪影