Commit f7c556ef authored by Johannes Braun's avatar Johannes Braun
Browse files

Reformatted advanced lib as raytrace lib

parent 4b89766a
......@@ -119,17 +119,18 @@ struct line_hit
struct Line
{
int triangle;
// line_hit nearest;
// line_hit farthest;
// int triangle;
line_hit nearest;
line_hit farthest;
};
struct Linespace
{
Line* lines;
uint p[2];
Bounds bounds;
uvec3 resolution;
float patch_size;
uint offsets[15];
uint line_count;
};
......@@ -139,11 +140,9 @@ struct Mesh
Vertex* vertices;
Triangle* triangles;
BVHNode* nodes;
Line* lines;
uint material;
uint id;
uint p[2];
Linespace linespace;
......
......@@ -2,7 +2,7 @@
#define __GL_MESH_DATASTRUCTURE
#include <raytracer/datastructure/mesh_bvh.glh>
#include <raytracer/datastructure/mesh_angular_linespace.glh>
#include <raytracer/datastructure/mesh_linespace.glh>
uniform bool u_use_ls;
......
......@@ -133,7 +133,7 @@ bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool
bool swapped = false;
uint line_id = ls__lineIndex(offset_ray, mesh, tmin, tmax, face_tmin, face_tmax, swapped);
Line line = mesh.lines[line_id];
Line line = mesh.linespace.lines[line_id];
line_hit near_data = swapped ? line.farthest : line.nearest;
Hit nearer;
......
#ifndef __GLARE_INCLUDE_ADVANCED
#define __GLARE_INCLUDE_ADVANCED
#include <advanced/IntersectionTests.h>
#include <raytrace/intersect.h>
#include <advanced/tracer/RayGenerator.h>
#include <advanced/tracer/Raytracer.h>
#include <raytrace/tracer/raygenerator.h>
#include <raytrace/tracer/pathtracer.h>
#include <advanced/meshlocal/LocalBVH.h>
#include <advanced/meshlocal/LocalCollector.h>
#include <advanced/meshlocal/SceneCollector.h>
#include <raytrace/data/local_collector.h>
#include <raytrace/data/global_collector.h>
#endif //!__GLARE_INCLUDE_ADVANCED
\ No newline at end of file
#include "Application.h"
#include <engine/graphics/ImageTexture2DMultisample.h>
#include <components/Rotator.h>
#include <openal/OpenAL.h>
#include <util/openal.h>
#include <engine/audio/AudioBuffer.h>
#include <engine/audio/AudioSource.h>
#include <engine/rendering/SplashScreen.h>
#include <linespace/LineSpace.h>
#include <advanced/meshlocal/AngularLinespace.h>
#include <raytrace/data/linespace.h>
#include <raytrace/data/angular_linespace.h>
#include <io/Export.h>
#include <util/files.h>
......@@ -42,7 +42,7 @@ namespace glare
m_gbuffer->updateSize(width, height);
m_config.window_width = width;
m_config.window_height = height;
m_collector->setDirty(glare::advanced::SceneCollector::DirtyFlags::eCamera);
m_collector->setDirty(glare::raytrace::SceneCollector::DirtyFlags::eCamera);
m_collector->collect();
gl::viewport(0, 0, width, height);
}
......@@ -233,16 +233,16 @@ namespace glare
void Application::initializeAdvanced()
{
m_collector = std::make_shared<advanced::SceneCollector>(core::EngineState::graph_root);
m_collector = std::make_shared<raytrace::SceneCollector>(core::EngineState::graph_root);
//Initialize Raytracer
m_raytracer = std::make_shared<advanced::Raytracer>(m_collector, std::make_shared<advanced::RayGeneratorDefault>());
m_raytracer = std::make_shared<raytrace::Pathtracer>(m_collector, std::make_shared<raytrace::RayGeneratorDefault>());
m_raytracer->setSkybox(m_skybox);
}
void Application::updateAdvanced()
{
m_collector->setDirty(advanced::SceneCollector::DirtyFlags::eAll);
m_collector->setDirty(raytrace::SceneCollector::DirtyFlags::eAll);
m_collector->collect(core::EngineState::graph_root);
m_raytracer->initialize(m_collector);
}
......@@ -306,10 +306,10 @@ namespace glare
switch (m_ray_gen_state)
{
case AppRayGenState::eDefault:
m_raytracer->setGenerator(std::make_shared<advanced::RayGeneratorDefault>());
m_raytracer->setGenerator(std::make_shared<raytrace::RayGeneratorDefault>());
break;
case AppRayGenState::eGBuffer:
m_raytracer->setGenerator(std::make_shared<advanced::RayGeneratorGBuffer>());
m_raytracer->setGenerator(std::make_shared<raytrace::RayGeneratorGBuffer>());
break;
default:
break;
......@@ -321,18 +321,18 @@ namespace glare
ImGui::PushID("id_samples");
ImGui::Title("Samples");
ImGui::ProgressBar(m_raytracer->currentSamples() / float(m_raytracer->maxSamples()), ImVec2(-1, 0), ("Current: " + std::to_string(m_raytracer->currentSamples()) + " of " + std::to_string(m_raytracer->maxSamples())).c_str());
ImGui::ProgressBar(m_raytracer->currentSample() / float(m_raytracer->getMaxSamples()), ImVec2(-1, 0), ("Current: " + std::to_string(m_raytracer->currentSample()) + " of " + std::to_string(m_raytracer->getMaxSamples())).c_str());
ImGui::Spacing();
int max_samples = m_raytracer->maxSamples();
int max_samples = m_raytracer->getMaxSamples();
ImGui::DragInt("Maximum", &max_samples, 10, 1, 50000);
if (max_samples != m_raytracer->maxSamples())
if (max_samples != m_raytracer->getMaxSamples())
m_raytracer->setMaxSamples(max_samples);
int spfr = m_raytracer->samplesPerFrame();
int spfr = m_raytracer->getSamplesPerFrame();
ImGui::DragInt("per frame", &spfr, 0.1f, 1, 10);
if (spfr != m_raytracer->samplesPerFrame())
if (spfr != m_raytracer->getSamplesPerFrame())
m_raytracer->setSamplesPerFrame(spfr);
ImGui::PopID();
......@@ -341,19 +341,19 @@ namespace glare
ImGui::PushID("id_bounces");
ImGui::TextWrapped("The global bounce limit clamps down all effect-dependant bounce limits to a unified maximum value.");
int bounces = m_raytracer->bounces();
int bounces = m_raytracer->getBounces();
ImGui::DragInt("Global Limit", &bounces, 0.1f, 0, 15);
if (bounces != m_raytracer->bounces())
if (bounces != m_raytracer->getBounces())
m_raytracer->setBounces(bounces);
if (ImGui::CollapsingHeader("Bounce Thresholds"))
{
drawEffectBounceControl("Diffuse", advanced::EffectType::eDiffuse);
drawEffectBounceControl("Translucent", advanced::EffectType::eTranslucent);
drawEffectBounceControl("Reflective", advanced::EffectType::eReflection);
drawEffectBounceControl("Refractive", advanced::EffectType::eRefraction);
drawEffectBounceControl("Transparence", advanced::EffectType::eTransparent);
drawEffectBounceControl("Emissive", advanced::EffectType::eEmissive);
drawEffectBounceControl("Diffuse", raytrace::EffectType::eDiffuse);
drawEffectBounceControl("Translucent", raytrace::EffectType::eTranslucent);
drawEffectBounceControl("Reflective", raytrace::EffectType::eReflection);
drawEffectBounceControl("Refractive", raytrace::EffectType::eRefraction);
drawEffectBounceControl("Transparence", raytrace::EffectType::eTransparent);
drawEffectBounceControl("Emissive", raytrace::EffectType::eEmissive);
}
ImGui::Spacing();
......@@ -459,7 +459,7 @@ namespace glare
ImGui::End();
}
void Application::drawLSBounceControl(const std::string &label, advanced::EffectType effect)
void Application::drawLSBounceControl(const std::string &label, raytrace::EffectType effect)
{
int val = m_raytracer->getLinespaceBounceThreshold(effect);
ImGui::DragInt(label.c_str(), &val, 0.1f, 0, m_raytracer->getEffectBounces(effect));
......@@ -469,7 +469,7 @@ namespace glare
}
}
void Application::drawEffectBounceControl(const std::string &label, advanced::EffectType effect)
void Application::drawEffectBounceControl(const std::string &label, raytrace::EffectType effect)
{
int val = m_raytracer->getEffectBounces(effect);
ImGui::DragInt(label.c_str(), &val, 0.1f, 0, 15);
......@@ -509,12 +509,12 @@ namespace glare
ImGui::Title("Bounce Thresholds");
ImGui::TextWrapped("The following threshold values will determine as of which bounce the Line Space should be used instead of the BVH. This can vary for every kind of effect.");
{
drawLSBounceControl("Diffuse", advanced::EffectType::eDiffuse);
drawLSBounceControl("Translucent", advanced::EffectType::eTranslucent);
drawLSBounceControl("Reflective", advanced::EffectType::eReflection);
drawLSBounceControl("Refractive", advanced::EffectType::eRefraction);
drawLSBounceControl("Transparency", advanced::EffectType::eTransparent);
drawLSBounceControl("Emissive", advanced::EffectType::eEmissive);
drawLSBounceControl("Diffuse", raytrace::EffectType::eDiffuse);
drawLSBounceControl("Translucent", raytrace::EffectType::eTranslucent);
drawLSBounceControl("Reflective", raytrace::EffectType::eReflection);
drawLSBounceControl("Refractive", raytrace::EffectType::eRefraction);
drawLSBounceControl("Transparency", raytrace::EffectType::eTransparent);
drawLSBounceControl("Emissive", raytrace::EffectType::eEmissive);
}
ImGui::End();
......
......@@ -47,8 +47,8 @@ namespace glare
void drawDebugWindow();
void drawSceneSelector();
void drawLinespaceControls();
void drawLSBounceControl(const std::string &label, advanced::EffectType effect);
void drawEffectBounceControl(const std::string &label, advanced::EffectType effect);
void drawLSBounceControl(const std::string &label, raytrace::EffectType effect);
void drawEffectBounceControl(const std::string &label, raytrace::EffectType effect);
//Scene
fs::path m_current_scene_root;
......@@ -61,8 +61,8 @@ namespace glare
std::shared_ptr<core::TextureRenderer> m_texture_renderer_default;
//Advanced
std::shared_ptr<advanced::SceneCollector> m_collector;
std::shared_ptr<advanced::Raytracer> m_raytracer;
std::shared_ptr<raytrace::SceneCollector> m_collector;
std::shared_ptr<raytrace::Pathtracer> m_raytracer;
AppRenderState m_render_state = AppRenderState::eGLDefault;
AppRayGenState m_ray_gen_state = AppRayGenState::eDefault;
......
#ifndef __MESHDATASTRUCTURE_H
#define __MESHDATASTRUCTURE_H
#include <vector>
#include <advanced/Structures.h>
#include <engine/rendering/Shader.h>
namespace glare
{
namespace advanced
{
/**
* @brief The base class for all mesh local Datastructures
* (or those which can be created from vectors of vertices and triangles alone).
*/
class LocalDatastructure
{
public:
/**
* @brief Executes the datastructure build process.
* @param vertices The mesh vertices referenced by the triangles.
* @param triangles The mesh triangle corner indices.
*/
virtual void apply(std::vector<math::Vertex> &vertices, std::vector<advanced::Triangle> &triangles) = 0;
/**
* @return Returns the buffer containing the full datastructure data.
*/
const core::Buffer<gl::BufferType::eShaderStorage> &buffer() const;
protected:
template<typename T>
void updateBufferData(const std::vector<typename T> &data);
std::shared_ptr<core::Buffer<gl::BufferType::eShaderStorage>> m_buffer;
};
inline const core::Buffer<gl::BufferType::eShaderStorage> &LocalDatastructure::buffer() const
{
return *m_buffer;
}
template<typename T>
void LocalDatastructure::updateBufferData(const std::vector<typename T> &data)
{
if (!m_buffer)
{
m_buffer = std::make_shared<core::Buffer<gl::BufferType::eShaderStorage>>();
}
m_buffer->upload(data, gl::BufferUsage::eDynamicRead);
m_buffer->makeResident(gl::Access::eReadOnly);
}
}
}
#endif //__MESHDATASTRUCTURE_H
#ifndef __AUDIOCORE_H
#define __AUDIOCORE_H
#include <openal/OpenAL.h>
#include <util/openal.h>
namespace glare
{
......
#include <memory>
#include <opengl/OpenGL.h>
#include <memory>
#include <util/opengl.h>
#include "GLWrapper.h"
#include "Time.h"
......
......@@ -231,6 +231,11 @@ namespace glare
return 2.f * glm::dot(glm::vec3(size.x, size.x, size.y), glm::vec3(size.y, size.z, size.z));
}
bool Bounds::empty() const
{
return glm::length(size()) == 0;
}
int Bounds::largest() const
{
const float max = glm::compMax(size());
......@@ -248,15 +253,15 @@ namespace glare
stream << "{ min: { " << min.x << ", " << min.y << ", " << min.z << " }, max: { " << max.x << ", " << max.y << ", " << max.z << " } }";
}
UniformBoundsSubdivision::UniformBoundsSubdivision(Bounds bounds, int max_subdivisions)
bounds_subdivision_t::bounds_subdivision_t(Bounds bounds, int max_subdivisions)
{
const int largest_axis = bounds.largest();
const glm::vec3 bounds_size = glm::max(glm::vec3(bounds.size().xyz), glm::vec3(1e-5f));
const float largest_axis_value = glm::compMax(bounds_size);
this->size = largest_axis_value / float(max_subdivisions);
subdivisions = glm::ivec3(0);
subdivisions[largest_axis] = max_subdivisions;
resolution = glm::ivec3(0);
resolution[largest_axis] = max_subdivisions;
for (unsigned char offset = 1; offset < 3; ++offset)
{
......@@ -266,14 +271,14 @@ namespace glare
while (side_size > 0)
{
side_size -= this->size;
++subdivisions[side];
++resolution[side];
}
}
}
size_t UniformBoundsSubdivision::childCount() const
size_t bounds_subdivision_t::childCount() const
{
return glm::compMul(subdivisions);
return glm::compMul(resolution);
}
Toggle::Toggle(bool v): m_value(v)
......
......@@ -243,20 +243,22 @@ namespace glare
float surface() const;
bool empty() const;
int largest() const;
void print(std::ostream &stream) const;
};
struct UniformBoundsSubdivision
struct bounds_subdivision_t
{
UniformBoundsSubdivision(): size(0)
{ }
UniformBoundsSubdivision(Bounds bounds, int max_subdivisions);
bounds_subdivision_t(): size(0) { }
bounds_subdivision_t(Bounds bounds, int max_subdivisions);
size_t childCount() const;
glm::ivec3 subdivisions;
glm::ivec3 resolution;
float size;
};
......
#ifndef __TIME_H
#define __TIME_H
#include <opengl/OpenGL.h>
#include <util/opengl.h>
#include <chrono>
#include <vector>
#include <stack>
......
#ifndef __AUDIOBUFFER_H
#define __AUDIOBUFFER_H
#include <openal/OpenAL.h>
#include <util/openal.h>
#include <util/audio.h>
namespace glare
......
#ifndef __AUDIOSOURCE_H
#define __AUDIOSOURCE_H
#include <openal/OpenAL.h>
#include <util/openal.h>
#include <engine/rendering/GraphNodeComponent.h>
#include "AudioBuffer.h"
......
......@@ -7,7 +7,7 @@
#include <vector>
#include <util/color.h>
#include <util/log.h>
#include <opengl/OpenGL.h>
#include <util/opengl.h>
#include <util/images.h>
namespace fs = std::experimental::filesystem;
......
......@@ -5,7 +5,7 @@
#include <vector>
// --- EXTERN ---------------------------------------------
#include <opengl/OpenGL.h>
#include <util/opengl.h>
#include <util/templates.h>
// --- INTERN ---------------------------------------------
......
......@@ -8,7 +8,7 @@
// --- EXTERN ---------------------------------------------
#include <util/log.h>
#include <opengl/OpenGL.h>
#include <util/opengl.h>
#include <util/templates.h>
// --- INTERN ---------------------------------------------
......
#include "OpenGLState.h"
#include <engine/EngineState.h>
#include <opengl/OpenGL.h>
#include <util/opengl.h>
namespace glare
{
......
......@@ -5,7 +5,7 @@
#include <memory>
#include <string>
#include <opengl/OpenGL.h>
#include <util/opengl.h>
#include <engine/rendering/Buffer.h>
#include <engine/rendering/VertexArray.h>
......
......@@ -242,14 +242,14 @@ namespace glare
last = content[--temp_pos];
}
Log_Debug << "Rebuilding Method call \"" << expression_name << "\" on object \"" << object << "\"";
// Log_Debug << "Rebuilding Method call \"" << expression_name << "\" on object \"" << object << "\"";
content = content.erase(temp_pos + 1, object.length() + 1);
content = content.insert(temp_pos + 2 + exp_length, object + (empty_call ? "" : ","));
pos = temp_pos;
Log_Debug << "Final restructure: " << "..." << content.substr(temp_pos + 1, exp_length + 6 + object.length()) << "...";
// Log_Debug << "Final restructure: " << "..." << content.substr(temp_pos + 1, exp_length + 6 + object.length()) << "...";
state = state_t::eIdle;
}
......
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