Commit 640017d7 authored by Johannes Braun's avatar Johannes Braun
Browse files

Added some parameters.

parent 647c93c8
......@@ -4,7 +4,7 @@ Size=353,64
Collapsed=0
[Scene]
Pos=-2,68
Pos=-3,66
Size=352,837
Collapsed=0
......
......@@ -47,11 +47,14 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m
}
else
{
if(mesh.traverseLineSpace(ray.makeRelative(mesh), use_first, current_t, hit, t_min)){
hit_triangle = true;
if (use_first)
{
return true;
for(int ls = 0; ls < mesh.num_linespaces; ++ls)
{
if(mesh.traverseLineSpace(ls, ray.makeRelative(mesh), use_first, current_t, hit, t_min)){
hit_triangle = true;
if (use_first)
{
return true;
}
}
}
}
......@@ -135,11 +138,14 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m
}
else
{
if(mesh.traverseLineSpace(ray.makeRelative(mesh), use_first, current_t, hit, t_min)){
hit_triangle = true;
if (use_first)
{
return true;
for(int ls = 0; ls < mesh.num_linespaces; ++ls)
{
if(mesh.traverseLineSpace(ls, ray.makeRelative(mesh), use_first, current_t, hit, t_min)){
hit_triangle = true;
if (use_first)
{
return true;
}
}
}
}
......
......@@ -67,12 +67,12 @@ uint offsetOf(const in Linespace linespace, uint inface, uint outface)
return offset;
}
uvec2 getPatch(const in Mesh mesh, vec3 at_position, int axis, int face){
uvec2 getPatch(const in Linespace linespace, vec3 at_position, int axis, int face){
bool flip_indices = face != axis;
return !flip_indices
? uvec2(at_position[face_width_axis[axis]] / mesh.linespaces[0].patch_size[face_width_axis[axis]], at_position[face_height_axis[axis]] / mesh.linespaces[0].patch_size[face_height_axis[axis]])
: uvec2(mesh.linespaces[0].resolution[face_width_axis[axis]], mesh.linespaces[0].resolution[face_height_axis[axis]]) -
uvec2(at_position[face_width_axis[axis]] / mesh.linespaces[0].patch_size[face_width_axis[axis]], at_position[face_height_axis[axis]] / mesh.linespaces[0].patch_size[face_height_axis[axis]])- 1;
? uvec2(at_position[face_width_axis[axis]] / linespace.patch_size[face_width_axis[axis]], at_position[face_height_axis[axis]] / linespace.patch_size[face_height_axis[axis]])
: uvec2(linespace.resolution[face_width_axis[axis]], linespace.resolution[face_height_axis[axis]]) -
uvec2(at_position[face_width_axis[axis]] / linespace.patch_size[face_width_axis[axis]], at_position[face_height_axis[axis]] / linespace.patch_size[face_height_axis[axis]])- 1;
}
struct PatchInfo
......@@ -84,9 +84,9 @@ struct PatchInfo
float t;
};
uint lineIndex(const in Ray ray, const in Mesh mesh, float tmin, float tmax, int face_in, int face_out, inout bool direction_swapped)
uint lineIndex(const in Ray ray, const in Mesh mesh, int ls_index, float tmin, float tmax, int face_in, int face_out, inout bool direction_swapped)
{
Linespace linespace = mesh.linespaces[0];
Linespace linespace = mesh.linespaces[ls_index];
PatchInfo entry_info;
PatchInfo exit_info;
......@@ -111,8 +111,8 @@ uint lineIndex(const in Ray ray, const in Mesh mesh, float tmin, float tmax, int
exit_info.axis = exit_info.face % 3;
// getPatch mirrors the patches on the negative axises per definition.
entry_info.patch_index = getPatch(mesh, entry_info.position, entry_info.axis, entry_info.face);
exit_info.patch_index = getPatch(mesh, exit_info.position, exit_info.axis, exit_info.face);
entry_info.patch_index = getPatch(linespace, entry_info.position, entry_info.axis, entry_info.face);
exit_info.patch_index = getPatch(linespace, exit_info.position, exit_info.axis, exit_info.face);
//Now with all that information, we can retrieve the line index.
uint offset = offsetOf(linespace, entry_info.face, exit_info.face);
......@@ -127,7 +127,7 @@ uint lineIndex(const in Ray ray, const in Mesh mesh, float tmin, float tmax, int
return offset + start + end;
}
bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool use_first, const in float max_distance, inout Hit hit, inout float t_min)
bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, const in bool use_first, const in float max_distance, inout Hit hit, inout float t_min)
{
float tmin;
float tmax;
......@@ -142,15 +142,15 @@ bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool
Ray offset_ray = local_ray;
offset_ray.origin += local_ray.direction * offset;
if(!offset_ray.intersectsBounds(mesh.linespaces[0].bounds, tmin, tmax, face_tmin, face_tmax) || t_min <= tmin-offset || tmin-offset > max_distance)
if(!offset_ray.intersectsBounds(mesh.linespaces[index].bounds, tmin, tmax, face_tmin, face_tmax) || t_min <= tmin-offset || tmin-offset > max_distance)
{
return false;
}
bool swapped = false;
uint line_id = lineIndex(offset_ray, mesh, tmin, tmax, face_tmin, face_tmax, swapped);
Line line_near = mesh.linespaces[0].lines[line_id * 2];
Line line_far = mesh.linespaces[0].lines[line_id * 2 + 1];
uint line_id = lineIndex(offset_ray, mesh, index, tmin, tmax, face_tmin, face_tmax, swapped);
Line line_near = mesh.linespaces[index].lines[line_id * 2];
Line line_far = mesh.linespaces[index].lines[line_id * 2 + 1];
int near_data = swapped ? line_far.triangle : line_near.triangle;
Hit nearer;
......
......@@ -23,11 +23,11 @@ struct Mesh
BVHNode* nodes;
Linespace* linespaces;
int num_linespaces;
uint material;
uint id;
int p[2];
//Linespace linespace;
int p;
mat4 transformation;
mat4 inverse_transformation;
......
......@@ -35,13 +35,19 @@ namespace glare::raytrace
generate(collector, max_subdivisions, generator);
}
void Linespace::generate(const LocalCollector &collector, int max_subdivisions, const Platform generator)
void Linespace::generate(const LocalCollector &collector, int max_subdivisions, const Platform generator = Platform::eCPU)
{
generate(collector, 1, 0, max_subdivisions, generator);
}
void Linespace::generate(const LocalCollector &collector, int uniform_grid_subdivision, int uniform_grid_index, int max_subdivisions, const Platform generator)
{
Log_Info << "Building Line Space for collector id " << collector.id() << "...";
core::ClockGL::instance().start();
m_bounds = collector.bounds();
m_subdivision = m_bounds.subdivide(max_subdivisions);
switch (generator)
{
default:
......
......@@ -94,6 +94,7 @@ namespace glare::raytrace
Linespace(const LocalCollector &collector, int max_subdivisions, const Platform generator = Platform::eCPU);
void generate(const LocalCollector &collector, const fs::path &settings_file);
void generate(const LocalCollector &collector, int max_subdivisions, const Platform generator = Platform::eCPU);
void generate(const LocalCollector &collector, int uniform_grid_subdivision, int uniform_grid_index, int max_subdivisions, const Platform generator = Platform::eCPU);
LinespaceData data() const;
const core::Buffer &lineBuffer() const;
......
......@@ -57,7 +57,6 @@ namespace glare::raytrace
m_triangle_buffer->makeResident(gl::Access::eReadOnly);
m_linespaces.resize(1, std::make_shared<Linespace>());
m_linespaces[0]->generate(*this, files::asset("preferences/linespace_default.xml"));
m_linespace_data.resize(1);
......@@ -103,7 +102,10 @@ namespace glare::raytrace
mesh.triangle_buffer_ptr = m_triangle_buffer->residentAddress();
if(!m_linespaces.empty() && !m_linespace_data.empty())
{
mesh.linespaces = static_cast<int>(m_linespace_data.size());
mesh.linespace_buffer_ptr = m_linespace_buffer.makeResident(gl::Access::eReadOnly);
}
//if (m_linespace) mesh.linespace = m_linespace->data();
......
......@@ -117,10 +117,11 @@ namespace glare::raytrace
uint64_t datastructure_buffer_ptr;
uint64_t linespace_buffer_ptr;
int linespaces;
glm::uint material;
glm::uint id;
int p[2];
int p;
//LinespaceData linespace;
......
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