簡體   English   中英

體積渲染光線投射偽像

[英]volume rendering raycasting artifacts

我正在嘗試在WebGL中實現簡單的光線投射體積渲染。

這是可行的,但是在旋轉音量時會出現一些偽像(即,頭部看起來變形了)。

在此處輸入圖片說明

現場演示: http//fnndsc.github.io/vjs/#shaders_raycasting_adibrain

用於調試的GLSL代碼: https : //github.com/FNNDSC/vjs/blob/master/src/shaders/shaders.raycasting.secondPass.frag

代碼的簡化版:

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;
}

我不明白什么能解釋這些假象。

可能是因為我不使用漸變來調節不透明度/顏色嗎?

任何提示將是非常歡迎的。

在射線投射的第一遍期間,背面坐標未正確計算。 “規范化”的coodinates的范圍不是[0,1]。 它是[-.5,1.5],因此創建了可視化工件,因為所有在[0,1]范圍之外的值都被鉗位了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM