sampling 3D textures

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Rusty Rooster
Posts: 11
Joined: Thu May 24, 2018 6:43 pm
Location: USA

sampling 3D textures

Post by Rusty Rooster »

Hi guys, I'm sampling a 128x128x64 texture and blending the results like so (in pixel shader) for raymarching:

Code: Select all

 
f1= texture2D(myTexture, vec2(x,y,slice z).r;
f2 =    texture2D(myTexture, vec2(x,y,slice z+1).r;
f=(z-int(z))*f2+(1.0-z+int(z))*f1;
 
It works and looks pretty good as far as the volume, but there's pretty big artifacts that I can't understand, like radio static. Any suggestions? I'm using GLSL.

EDIT: To clarify, I have a 1024x1024 texture that I'm indexing as if it were 64 128x128 regions. It's not a problem with the texture or the math itself as far as I can tell.
Last edited by Rusty Rooster on Sun Oct 18, 2020 12:32 am, edited 1 time in total.
Rusty Rooster
Posts: 11
Joined: Thu May 24, 2018 6:43 pm
Location: USA

Re: sampling 3D textures

Post by Rusty Rooster »

Image

All of the weird green lines and planes are unwanted artifacts
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: sampling 3D textures

Post by devsh »

you're using the wrong GLSL function? does that shader even compile? you dont have a bracket at the end of texture2D

it should be `sampler3D` and the function to sample `texture3D`
Post Reply