22 lines
No EOL
711 B
Text
22 lines
No EOL
711 B
Text
#include "../math/const.msl"
|
|
|
|
/*
|
|
contributors: Patricio Gonzalez Vivo
|
|
description: equirect 2D projection to 3D vector
|
|
use: <float3> equirect2xyz(<float2> uv)
|
|
license:
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
*/
|
|
|
|
#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 |