+ | Basic camera but glitched for now

This commit is contained in:
TheRedShip
2024-12-21 21:17:35 +01:00
parent d92b2ca913
commit df44327436
10 changed files with 93 additions and 25 deletions

View File

@ -2,6 +2,8 @@
out vec4 FragColor;
uniform vec2 u_resolution;
uniform vec3 u_cameraPosition;
uniform mat4 u_viewMatrix;
vec3 sphereCenter = vec3(0.0, 0.0, -5.0);
float sphereRadius = 1.0;
@ -55,10 +57,10 @@ void main()
uv = uv * 2.0 - 1.0;
uv.x *= u_resolution.x / u_resolution.y;
vec3 rayOrigin = vec3(0.0, 0.0, 0.0);
vec3 rayDirection = normalize(vec3(uv, -1.0));
rayDirection = (u_viewMatrix * vec4(rayDirection, 0.0)).xyz;
Ray ray = Ray(rayOrigin, rayDirection);
Ray ray = Ray(u_cameraPosition, rayDirection);
float t;
if (intersectSphere(ray, sphereCenter, sphereRadius, t))