# 3D texture rendering artifacts

Hi all,

I have encountered a problem of rendering artifacts of 3D texture as below:

Rendering artifacts(texture get hidden when viewed from certain angle)

I have searched on net as to find solution of this problem, and most answer pointed towards the problem in regards of depth buffer bit.
While i have tried to change the depth buffer bit to 24 bit from GL_DEPTH to GL_STENCIL in GLUT, the result remains the same as the texture(or geometry-not really sure) get hidden when viewed from certain angle…

So, can i know what is exactly the problem that results in this kind of artifacts??

Below is the fragment shader code snippet(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++) {
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;
}
``````

Thanks a lot…
{"ft_lang_label":"__label__en","ft_lang_prob":0.72794944,"math_prob":0.95268977,"size":1530,"snap":"2022-27-2022-33","text_gpt3_token_len":408,"char_repetition_ratio":0.106815204,"word_repetition_ratio":0.016806724,"special_character_ratio":0.26993465,"punctuation_ratio":0.14237288,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97382647,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-30T10:05:19Z\",\"WARC-Record-ID\":\"<urn:uuid:91f8c7d5-fb3c-4d1f-b882-dcd0b386aef5>\",\"Content-Length\":\"15474\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:253538bb-b3a6-4b4c-b2b6-e7c06b274724>\",\"WARC-Concurrent-To\":\"<urn:uuid:977e2a08-5feb-46c3-b42f-70cd72f4bd7f>\",\"WARC-IP-Address\":\"68.183.55.73\",\"WARC-Target-URI\":\"https://community.khronos.org/t/3d-texture-rendering-artifacts/73270\",\"WARC-Payload-Digest\":\"sha1:2LLJD3P52SVUN2HY4CDXJDRHHI3EQ4J7\",\"WARC-Block-Digest\":\"sha1:6VCLMTGNTKBRUSOKCEEBBWQDXPVSIO73\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103671290.43_warc_CC-MAIN-20220630092604-20220630122604-00675.warc.gz\"}"}