LYGIA Shader Library

equirect2xyz (lygia/space/equirect2xyz)

equirect 2D projection to 3D vector

Dependencies:

Use:

<vec3> equirect2xyz(<vec2> uv)

Check it on Github



#ifndef FNC_EQUIRECT2XYZ
#define FNC_EQUIRECT2XYZ
vec3 equirect2xyz(vec2 uv) {
    float Phi = PI - uv.y * PI;
    float Theta = uv.x * TWO_PI;
    vec3 dir = vec3(cos(Theta), 0.0, sin(Theta));
    dir.y   = cos(Phi);//clamp(cos(Phi), MinCos, 1.0);
    dir.xz *= sqrt(1.0 - dir.y * dir.y);
    return dir;
}
#endif

Dependencies:

Use:

<float3> equirect2xyz(<float2> uv)

Check it on Github



#ifndef FNC_EQUIRECT2XYZ
#define FNC_EQUIRECT2XYZ
float3 equirect2xyz(float2 uv) {
    float Phi = PI - uv.y * PI;
    float Theta = uv.x * TWO_PI;
    float3 dir = float3(cos(Theta), 0.0, sin(Theta));
    dir.y   = cos(Phi);//clamp(cos(Phi), MinCos, 1.0);
    dir.xz *= sqrt(1.0 - dir.y * dir.y);
    return dir;
}
#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