ashima / webgl-noise

Procedural Noise Shader Routines compatible with WebGL
MIT License
2.8k stars 302 forks source link

pnoise is not repeating #4

Closed pyalot closed 13 years ago

pyalot commented 13 years ago

If noise is rendered per fragment, and the attached texture to the FBO is 512x512 pixels, then the gl_FragCoords go from 0.5 ... 511.5, using a period of 512 does not tile properly:

float value = pnoise(gl_FragCoord.xy_0.1, vec2(512.0_0.1)); // does not work

stegu commented 13 years ago

The repeat you would want is not 512 in this case, but 51.2 (0.1 times 512), and that is not an integer period. Use even multiples, like gl_FragCoord*(1.0/8.0) and a corresponding period of 64.0, and it should work. If not, let me know. The "pnoise" functions are not that well tested yet.

pyalot commented 13 years ago

using an integer even division works, please mention that in the sourcecode comments to pnoise.

stegu commented 13 years ago

Good point. I have been using pnoise in RenderMan SL for ages, and the restriction to integer periods is well known in that context, but it deserves a better explanation here. (In general, I should document all the functions better.)