Scale pcg::perlin output to [0,1]

This commit is contained in:
Nikita Lisitsa 2020-09-13 10:36:44 +03:00
parent 7697adcc68
commit 1cfdde033b

View file

@ -44,7 +44,8 @@ namespace psemek::pcg
float const d01 = tx * grad_map_(ix, iy+1)[0] + (ty-1.f) * grad_map_(ix, iy+1)[1];
float const d11 = (tx-1.f) * grad_map_(ix+1, iy+1)[0] + (ty-1.f) * grad_map_(ix+1, iy+1)[1];
return smoothstep(smoothstep(d00, d10, tx), smoothstep(d01, d11, tx), ty);
float v = smoothstep(smoothstep(d00, d10, tx), smoothstep(d01, d11, tx), ty) * std::sqrt(2.f);
return 0.5f + v * 0.5f;
}
}