I feel like my logic isnt too awful here. I am trying to convert a planeGeometry into a sphere using its UV coordinates as latitude and longitude. Essentially here is the logic:
- convert uv coordinates to lat/long respectively
- change lat/long over to radians
- convert to x,y,z catesian coordinates
heres the code for the vertex shader im trying out:
varying vec2 vUv;
#define PI 3.14159265359
void main() {
vUv = uv;
float lat = (uv.x - 0.5) * 90.0;
float lon = abs((uv.y - 0.5) * 180.0);
float latRad = lat * (PI / 180.0);
float lonRad = lon * (PI / 180.0);
float x = sin(latRad) * sin(lonRad);
float y = cos(latRad);
float z = cos(latRad) * sin(lonRad);
gl_Position = projectionMatrix * modelViewMatrix * vec4(x,y,z, 0.5);
}
Any advice is appreciated, I feel like I am just missing something small with the logic but I believe in the masses.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment