[英]Visible edges from Opengl 3d texture
我從體積數據的體積渲染中遇到了立方體的可見邊緣,這種情況發生在在立方體邊緣進行查看時。
僅供參考,工件如下:
僅供參考,片段着色器代碼片段如下(OpenGL開發手冊):
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;
}
僅供參考,使用glTexImage3D加載紋理,其格式為GL_RED,尺寸為556x614x201
僅供參考,通過將mipmapping的插值參數從GL_LINEAR_MIPMAP_LINEAR更改為GL_LINEAR可以解決此問題。
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.