I am trying out some volume rendering but I have hit a brick wall. I have a vertex shader that gives the fragment shader it’s world-space coordinates, and from those coordinates the fragment shader outputs the density of the volume by interpolating between horizontal planes.

```
//shader.frag:
uniform sampler2D m_Noise; //perlin noise image
varying vec2 uv; //uv is the 2D coordinate on the quad
varying vec3 ijk; //ijk is the world-space coordinate of the fragment
void main() {
vec2 xz = (ijk.xz + 100) / 500.0;
float y = ijk.y;
float j = floor(y);
float f = 0.234 * j; //0.234 is a random number. The artifacts
float g = 0.234 * (j + 1); //appear when this number is not an integer
float a = texture2D(m_Noise, frac(xz + f)).r; //lower layer (a translation of the image)
float b = texture2D(m_Noise, frac(xz + g)).r; //upper layer (a translation of the image)
float c = mix(a, b, frac(y)); //linear interpolation between the layers
gl_FragColor = vec4(vec3(1), c);
}
```

However, whenever the `0.234`

value is not a mathematical integer, horizontal artifacts only appear where the `floor(/* y-coordinate of fragment */)`

is close to `0`

:

These lines appear and disappear randomly as the camera moves around or closer/farther from the quad. How can I fix this?