mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
~ | Small tweaks
This commit is contained in:
@ -74,6 +74,10 @@ bool intersectTriangle(Ray ray, GPUTriangle obj, out hitInfo hit)
|
||||
|
||||
vec3 pvec = cross(ray.direction, vertex2);
|
||||
float det = dot(vertex1, pvec);
|
||||
|
||||
if (abs(det) < 1e-8)
|
||||
return (false);
|
||||
|
||||
vec3 tvec = ray.origin - obj.position;
|
||||
|
||||
float invDet = 1.0 / det;
|
||||
@ -82,8 +86,7 @@ bool intersectTriangle(Ray ray, GPUTriangle obj, out hitInfo hit)
|
||||
float v = dot(ray.direction, qvec) * invDet;
|
||||
float t = dot(vertex2, qvec) * invDet;
|
||||
|
||||
bool valid = abs(det) > 1e-8 &&
|
||||
u >= 0.0 && u <= 1.0 &&
|
||||
bool valid = u >= 0.0 && u <= 1.0 &&
|
||||
v >= 0.0 && (u + v) <= 1.0 &&
|
||||
t > 0.0;
|
||||
|
||||
|
@ -41,7 +41,7 @@ vec3 sampleSphereLight(vec3 position, GPUObject obj, int light_index, GPUMateria
|
||||
return vec3(0.0);
|
||||
|
||||
float cos_theta = max(0.0, -dot(light_dir, normalize(sample_point - obj.position)));
|
||||
return mat.emission * mat.color / (light_dist); // * cos_theta / (4.0 * M_PI * (obj.radius / 2.0) * (obj.radius / 2.0));
|
||||
return mat.emission * mat.color / (light_dist * light_dist) * cos_theta / (4.0 * M_PI * (obj.radius / 2.0) * (obj.radius / 2.0));
|
||||
}
|
||||
|
||||
vec3 sampleQuadLight(vec3 position, GPUObject obj, int light_index, GPUMaterial mat, inout uint rng_state)
|
||||
@ -65,7 +65,7 @@ vec3 sampleQuadLight(vec3 position, GPUObject obj, int light_index, GPUMaterial
|
||||
|
||||
vec3 normal = normalize(crossQuad);
|
||||
float cos_theta = max(0.0, dot(normal, -light_dir));
|
||||
return mat.emission * mat.color / (light_dist); // * cos_theta / pdf;
|
||||
return mat.emission * mat.color / (light_dist);
|
||||
}
|
||||
|
||||
vec3 sampleLights(vec3 position, inout uint rng_state)
|
||||
|
Reference in New Issue
Block a user