Commit 00579b3c authored by Johannes Braun's avatar Johannes Braun
Browse files

Fixed some issues with flat objects.

parent 39f14ab3
...@@ -71,7 +71,6 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m ...@@ -71,7 +71,6 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m
else else
{ {
Ray local_ray = ray.makeRelative(mesh); Ray local_ray = ray.makeRelative(mesh);
Bounds mesh_bounds = mesh.nodes[0].bounds; Bounds mesh_bounds = mesh.nodes[0].bounds;
float temp_tmin, temp_tmax; float temp_tmin, temp_tmax;
...@@ -201,21 +200,24 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m ...@@ -201,21 +200,24 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m
{ {
Ray local_ray = ray.makeRelative(mesh); Ray local_ray = ray.makeRelative(mesh);
Bounds mesh_bounds = mesh.nodes[0].bounds; Bounds mesh_bounds = mesh.nodes[0].bounds;
float temp_tmin, temp_tmax;
if(local_ray.intersectsBounds(mesh_bounds, current_t)) if(local_ray.intersectsBounds(mesh_bounds, temp_tmin, temp_tmax, current_t))
{ {
vec3 voxel_size = mesh_bounds.size().xyz / vec3(mesh.grid_linespace.grid_resolution); vec3 voxel_size = mesh_bounds.size().xyz / vec3(mesh.grid_linespace.grid_resolution);
vec3 origin = local_ray.origin + int(temp_tmin == temp_tmax) * temp_tmin * local_ray.direction;
vec3 step = sign(local_ray.direction); vec3 step = sign(local_ray.direction);
vec3 delta = step / local_ray.direction * voxel_size; vec3 delta = step / local_ray.direction * voxel_size;
vec3 position = (local_ray.origin - mesh_bounds.min.xyz) / voxel_size; vec3 position = (origin - mesh_bounds.min.xyz) / voxel_size;
ivec3 index = clamp(ivec3(position), ivec3(0), mesh.grid_linespace.grid_resolution-1); ivec3 index = clamp(ivec3(position), ivec3(0), mesh.grid_linespace.grid_resolution-1);
ivec3 totalStepSign = ivec3(greaterThan(step, ivec3(0))); ivec3 totalStepSign = ivec3(greaterThan(step, ivec3(0)));
//bool x; //bool x;
//int a = x + (1-2*x)*blub; //int a = x + (1-2*x)*blub;
// x true -> x = 1, a = 1 - blub; // x true -> x = 1, a = 1 - blub;
// x false -> x = 0, a = 0+0*b // x false -> x = 0, a = 0 - (-1)*blub = blub
vec3 tnext = (totalStepSign + (1-2*totalStepSign) * (position - index)) * delta; vec3 tnext = (totalStepSign + (1-2*totalStepSign) * (position - index)) * delta;
float temp_t_min = 0.f; float temp_t_min = 0.f;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment