OpenSimplex2 icon indicating copy to clipboard operation
OpenSimplex2 copied to clipboard

What is the difference between the GLSL OpenSimplex2S and C# OpenSimplex2S?

Open cloutiertyler opened this issue 5 years ago • 4 comments

I'm trying to understand the difference between the GLSL* and C# versions of the algorithm. I created textures from both of them and although they actual values are not identical, the quality of the noise looks identical. Is the GLSL version of the noise supposed to be somehow inferior because it cannot store the perm and permGrad states?

If I wanted identical versions on the CPU and GPU, would I be good to just translate the GLSL version directly to C#?

Also want to say, thanks so much for creating OpenSimplex! It's really awesome stuff. :)

*by the GLSL version I mean bccNoise8Point.glsl specifically.

cloutiertyler avatar May 02 '20 06:05 cloutiertyler

I implemented the GLSL version in Unity if you'd like to see that code. The end result looks great and matches exactly with the GLSL version.

cloutiertyler avatar May 04 '20 05:05 cloutiertyler

image

cloutiertyler avatar May 04 '20 05:05 cloutiertyler

Here's a texture I created which is set up to show the most prominent artifacts I could find. They're only very subtle even still.

cloutiertyler avatar May 04 '20 05:05 cloutiertyler

The GLSL version compares the actual plane boundaries between points to determine which are closer, while the C# version uses a sequence of points to check until it has found all of the points in range. The latter I found to be faster on the CPU, at least while testing in Java. But the GLSL one could very well be ported to C#! The main difference in how they look, as far as the actual values go, comes from the hash function. The GLSL code uses a permutation polynomial, while the C#/Java code use a permute table. Aside from that, the possible gradients at each vertex are the same.

Slight artifacts while zoomed out come from the underlying triangular alignment. Those would show up with either implementation.

KdotJPG avatar Jul 06 '20 17:07 KdotJPG