Skip to main content
1 of 2

Strange shader behavior OPENGL

I have found strange behavior programming perlin noise as OpenGL shader. Code

 float left = lerp(fade(v),  downleft,  topleft);
 float right = lerp(fade(v), downright, topright);
 float result = lerp(fade(u), left, right);

produces desired effect. After changing it to

float result = lerp(fade(u), lerp(fade(v),  downleft,  topleft), lerp(fade(v), downright, topright));

(I only plugged right and left definitions into result)

code behaves completely different and there are visible edges in my perlin noise. Below both results: enter image description here

The wole shader(30 lines) is here. I dont want to make this mistake again but still I dont know what is the difference beetween those. Can anybody give me a hint?

By the way I will be happy to hear any remarks on my code as I am new to shader and OpenGL graphics.

Thanks!