* | cleaning

This commit is contained in:
TheRedShip
2025-01-06 17:13:31 +01:00
parent 5a6fd1f9ef
commit a06e1f80a8
2 changed files with 7 additions and 4 deletions

View File

@ -130,9 +130,6 @@ void main()
vec2 uv = (vec2(pixel_coords) / u_resolution) * 2.0 - 1.0;; vec2 uv = (vec2(pixel_coords) / u_resolution) * 2.0 - 1.0;;
uv.x *= u_resolution.x / u_resolution.y; uv.x *= u_resolution.x / u_resolution.y;
uint rng_state = uint(u_resolution.x) * uint(pixel_coords.y) + pixel_coords.x;
rng_state = rng_state + u_frameCount * 719393;
float fov = 90.0; float fov = 90.0;
float focal_length = 1.0 / tan(radians(fov) / 2.0); float focal_length = 1.0 / tan(radians(fov) / 2.0);
@ -141,6 +138,9 @@ void main()
vec3 ray_direction = normalize((inverse(u_viewMatrix) * vec4(view_space_ray, 0.0)).xyz); vec3 ray_direction = normalize((inverse(u_viewMatrix) * vec4(view_space_ray, 0.0)).xyz);
Ray ray = Ray(u_cameraPosition, ray_direction); Ray ray = Ray(u_cameraPosition, ray_direction);
uint rng_state = uint(u_resolution.x) * uint(pixel_coords.y) + pixel_coords.x;
rng_state = rng_state + u_frameCount * 719393;
vec3 color = pathtrace(ray, rng_state); vec3 color = pathtrace(ray, rng_state);
float blend = 1.0 / float(u_frameCount + 1); float blend = 1.0 / float(u_frameCount + 1);

View File

@ -33,9 +33,12 @@ bool intersectQuad(Ray ray, GPUObject obj, out hitInfo hit)
{ {
vec3 normal = normalize(cross(obj.vertex1, obj.vertex2)); vec3 normal = normalize(cross(obj.vertex1, obj.vertex2));
float d = dot(normal, ray.direction); float d = dot(normal, ray.direction);
if (d == 0.0) return (false);
float t = dot(obj.position - ray.origin, normal) / d; float t = dot(obj.position - ray.origin, normal) / d;
if (t <= 0.0 || d == 0.0) return (false); if (t <= 0.0) return (false);
vec3 p = ray.origin + ray.direction * t - obj.position; vec3 p = ray.origin + ray.direction * t - obj.position;