LYGIA Shader Library

round (lygia/v1.2.0/math/round)

round a value to the nearest integer

Use:

round(<float|vec2|vec3|vec4> value)

Check it on Github


#ifndef FNC_ROUND
#define FNC_ROUND
float round(float x) { return sign(x)*floor(abs(x)+0.5); }
vec2 round(vec2 x) { return sign(x)*floor(abs(x)+0.5); }
vec3 round(vec3 x) { return sign(x)*floor(abs(x)+0.5); }
vec4 round(vec4 x) { return sign(x)*floor(abs(x)+0.5); }
#endif

License

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository