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

Reduced number of effects to be set up to fit bsdf model

parent cbfc9266
<pathtracer version="1.0"> <pathtracer version="1.0">
<group name="bounces"> <group name="bounces">
<item name="diffuse" value="4"/> <item name="diffusion" value="5"/>
<item name="translucent" value="4"/> <item name="reflection" value="6"/>
<item name="reflect" value="5"/> <item name="transmission" value="10"/>
<item name="refract" value="8"/> <item name="emission" value="1"/>
<item name="transparent" value="9"/>
<item name="emissive" value="1"/>
</group> </group>
<group name="ls-thresholds"> <group name="ls-thresholds">
<item name="diffuse" value="4"/> <item name="diffusion" value="3"/>
<item name="translucent" value="4"/> <item name="reflection" value="3"/>
<item name="reflect" value="5"/> <item name="transmission" value="3"/>
<item name="refract" value="8"/> <item name="emission" value="1"/>
<item name="transparent" value="9"/>
<item name="emissive" value="1"/>
<item name="accuracy" value="0.4"/> <item name="accuracy" value="0.4"/>
<item name="shadow" value="0.04"/> <item name="shadow" value="0.04"/>
......
...@@ -44,22 +44,22 @@ uniform struct ...@@ -44,22 +44,22 @@ uniform struct
uint getBounceAmount(const in Trace trace, uint id) uint getBounceAmount(const in Trace trace, uint id)
{ {
return (trace.properties.bounce_amount >> (4*id)) & 0xF; return (trace.properties.bounce_amount >> (8*id)) & 0xFF;
} }
void addBounceAmount(inout Trace trace, uint id, uint amount) void addBounceAmount(inout Trace trace, uint id, uint amount)
{ {
trace.properties.bounce_amount += (amount & 0xF) << (4*id); trace.properties.bounce_amount += (amount & 0xFF) << (8*id);
} }
uint getLSBounceThreshold(uint id) uint getLSBounceThreshold(uint id)
{ {
return (u_linespace_properties.bounce_thresholds >> (4*id)) & 0xF; return (u_linespace_properties.bounce_thresholds >> (8*id)) & 0xFF;
} }
uint getBounceThreshold(uint id) uint getBounceThreshold(uint id)
{ {
return (u_render_config.bounce_thresholds >> (4*id)) & 0xF; return (u_render_config.bounce_thresholds >> (8*id)) & 0xFF;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
......
...@@ -50,7 +50,7 @@ int main(int argc, char* argv[]) ...@@ -50,7 +50,7 @@ int main(int argc, char* argv[])
// Sun light source // Sun light source
auto sun_node = std::make_shared<core::GraphNode>("light_sun"); auto sun_node = std::make_shared<core::GraphNode>("light_sun");
sun_node->transform()->rotate({ glm::radians(80.f), 0, 0 }); sun_node->transform()->rotate({ glm::radians(80.f), 0, 0 });
auto light_sun = sun_node->makeComponent<core::LightComponent>(color::rgba32f{ 0.4f, 0.4f, 0.4f, 1.f }, core::Attenuation{ 1,0,0 }, core::LightParameters::makeDirectionalLight()); auto light_sun = sun_node->makeComponent<core::LightComponent>(color::rgba32f{ 0.4f, 0.4f, 0.4f, 1.f }, core::Attenuation{ 1,0,0 }, core::LightParameters::makeDirectionalLight(0.1f));
// Make Environment lighting node // Make Environment lighting node
auto lighting_node = std::make_shared<core::GraphNode>("environment"); auto lighting_node = std::make_shared<core::GraphNode>("environment");
......
...@@ -253,13 +253,12 @@ namespace glare ...@@ -253,13 +253,12 @@ namespace glare
std::shared_ptr<core::Material> Map::makeMaterial() std::shared_ptr<core::Material> Map::makeMaterial()
{ {
std::shared_ptr<core::Material> material = std::make_shared<core::Material>("terrain"); std::shared_ptr<core::Material> material = std::make_shared<core::Material>("terrain");
material->color_diffuse = color::preset::white.rgb; material->base.value = color::preset::white.rgb;
material->color_specular = 2 * color::preset::white.rgb; material->roughness.value = 0.2f;
material->specular_exponent = 80; material->base.texture = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048.png"));
material->map_diffuse = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048.png"));
material->map_normal = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_n.png")); material->map_normal = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_n.png"));
material->map_displacement = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_h.png")); material->map_displacement = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_h.png"));
material->map_specular = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_s.png")); material->roughness.texture = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_s.png"));
return material; return material;
} }
......
...@@ -233,16 +233,14 @@ void drawDebugGui() ...@@ -233,16 +233,14 @@ void drawDebugGui()
static auto effectBounces = [](const std::string &label, raytrace::EffectType effect) static auto effectBounces = [](const std::string &label, raytrace::EffectType effect)
{ {
int val = pathtracer->getEffectBounces(effect); int val = pathtracer->getEffectBounces(effect);
if (ImGui::DragInt(label.c_str(), &val, 0.1f, 0, 15)) if (ImGui::DragInt(label.c_str(), &val, 0.1f, 0, 255))
pathtracer->setEffectBounces(effect, uint8_t(val)); pathtracer->setEffectBounces(effect, uint8_t(val));
}; };
effectBounces("Diffuse", raytrace::EffectType::eDiffuse); effectBounces("Diffusion", raytrace::EffectType::eDiffusion);
effectBounces("Translucent", raytrace::EffectType::eTranslucent); effectBounces("Reflection", raytrace::EffectType::eReflection);
effectBounces("Reflective", raytrace::EffectType::eReflection); effectBounces("Transmission", raytrace::EffectType::eTransmission);
effectBounces("Refractive", raytrace::EffectType::eRefraction); effectBounces("Emission", raytrace::EffectType::eEmission);
effectBounces("Transparency", raytrace::EffectType::eTransparent);
effectBounces("Emissive", raytrace::EffectType::eEmissive);
ImGui::TreePop(); ImGui::TreePop();
} }
} }
...@@ -293,12 +291,10 @@ void drawDebugGui() ...@@ -293,12 +291,10 @@ void drawDebugGui()
pathtracer->setLinespaceBounceThresholds(effect, uint8_t(val)); pathtracer->setLinespaceBounceThresholds(effect, uint8_t(val));
}; };
bounceControl("Diffuse", raytrace::EffectType::eDiffuse); bounceControl("Diffusion", raytrace::EffectType::eDiffusion);
bounceControl("Translucent", raytrace::EffectType::eTranslucent); bounceControl("Reflection", raytrace::EffectType::eReflection);
bounceControl("Reflective", raytrace::EffectType::eReflection); bounceControl("Transmission", raytrace::EffectType::eTransmission);
bounceControl("Refractive", raytrace::EffectType::eRefraction); bounceControl("Emission", raytrace::EffectType::eEmission);
bounceControl("Transparence", raytrace::EffectType::eTransparent);
bounceControl("Emissive", raytrace::EffectType::eEmissive);
} }
} }
......
...@@ -12,42 +12,7 @@ ...@@ -12,42 +12,7 @@
namespace glare namespace glare
{ {
namespace raytrace namespace raytrace
{ {
enum class BVHNodeType
{
eInner = 0,
eLeaf = 1
};
struct bvh_node_t
{
math::Bounds bounds;
BVHNodeType type;
//Children, can be either child nodes or array start- and end indices.
uint32_t left_idx;
uint32_t right_idx;
//Parent
uint32_t parent;
};
struct index_range_t
{
uint32_t start;
uint32_t end;
uint32_t parent; //Parent node index
uint32_t padding;
};
/**
* Bins are used in the split(...) method of the MeshBVH for the Binned SAH Split algorithm.
*/
struct bin_t
{
math::Bounds bounds;
int object_count;
};
/** /**
* @brief An abstraction class for the huge, but well reusable parts of a BVH. Included are a construction algorithm based on the binned SAH split, as well as a stackless traversal method. * @brief An abstraction class for the huge, but well reusable parts of a BVH. Included are a construction algorithm based on the binned SAH split, as well as a stackless traversal method.
...@@ -55,7 +20,44 @@ namespace glare ...@@ -55,7 +20,44 @@ namespace glare
template<typename TPrimitive> template<typename TPrimitive>
class BVH class BVH
{ {
public: public:
struct Node
{
enum class Type
{
eInner = 0,
eLeaf = 1
};
math::Bounds bounds;
Type type;
//Children, can be either child nodes or array start- and end indices.
uint32_t left_idx;
uint32_t right_idx;
//Parent
uint32_t parent;
};
struct IndexRange
{
uint32_t start;
uint32_t end;
uint32_t parent; //Parent node index
uint32_t padding;
};
/**
* Bins are used in the split(...) method of the MeshBVH for the Binned SAH Split algorithm.
*/
struct Bin
{
math::Bounds bounds;
int object_count;
};
BVH() {}; BVH() {};
~BVH() {}; ~BVH() {};
...@@ -65,7 +67,7 @@ namespace glare ...@@ -65,7 +67,7 @@ namespace glare
* @param centroid_from_id A function that should return a centroid coordinate for the parameter id (referring to the index in the primitive list). * @param centroid_from_id A function that should return a centroid coordinate for the parameter id (referring to the index in the primitive list).
* @param node_from_range A function that builds a bvh_node_t containing all primitives from index "start" to index "end". * @param node_from_range A function that builds a bvh_node_t containing all primitives from index "start" to index "end".
*/ */
void build(std::vector<TPrimitive> &primitives, std::function<glm::vec4(int id)> centroid_from_id, std::function<bvh_node_t(int start, int end)> node_from_range); void build(std::vector<TPrimitive> &primitives, std::function<glm::vec4(int id)> centroid_from_id, std::function<Node(int start, int end)> node_from_range);
/** /**
* @brief The stackless traversal, also based on parameter functions for core functionality. * @brief The stackless traversal, also based on parameter functions for core functionality.
...@@ -77,13 +79,13 @@ namespace glare ...@@ -77,13 +79,13 @@ namespace glare
bool traverse(const Ray &ray, float max_distance, bool finish_after_hit, std::function<bool(const Ray &ray, float max_distance, bool finish_after_hit, int primitive_id)> check_traversal_primitive) const; bool traverse(const Ray &ray, float max_distance, bool finish_after_hit, std::function<bool(const Ray &ray, float max_distance, bool finish_after_hit, int primitive_id)> check_traversal_primitive) const;
const core::Buffer<gl::BufferType::eShaderStorage>& buffer() const; const core::Buffer<gl::BufferType::eShaderStorage>& buffer() const;
const std::vector<bvh_node_t> &nodes() const; const std::vector<Node> &nodes() const;
private: private:
void reset(std::vector<TPrimitive> &primitives); void reset(std::vector<TPrimitive> &primitives);
void split(std::vector<TPrimitive> &primitives, uint32_t global_id); void split(std::vector<TPrimitive> &primitives, uint32_t global_id);
std::function<bvh_node_t(int start, int end)> m_node_from_range; std::function<Node(int start, int end)> m_node_from_range;
std::function<glm::vec4(int id)> m_centroid_from_id; std::function<glm::vec4(int id)> m_centroid_from_id;
const int32_t m_bin_count = 16; const int32_t m_bin_count = 16;
...@@ -92,12 +94,12 @@ namespace glare ...@@ -92,12 +94,12 @@ namespace glare
core::Buffer<gl::BufferType::eShaderStorage> m_node_buffer; core::Buffer<gl::BufferType::eShaderStorage> m_node_buffer;
std::vector<bvh_node_t> m_nodes; std::vector<Node> m_nodes;
std::vector<math::Bounds> m_centroid_boxes; std::vector<math::Bounds> m_centroid_boxes;
std::vector<math::Bounds> m_safe_centroid_boxes; std::vector<math::Bounds> m_safe_centroid_boxes;
std::vector<index_range_t> m_ranges; std::vector<IndexRange> m_ranges;
std::vector<index_range_t> m_safe_ranges; std::vector<IndexRange> m_safe_ranges;
std::vector<glm::vec4> m_centroids; std::vector<glm::vec4> m_centroids;
std::atomic_int m_buffer_position; std::atomic_int m_buffer_position;
...@@ -116,7 +118,7 @@ namespace glare ...@@ -116,7 +118,7 @@ namespace glare
} }
template<typename TPrimitive> template<typename TPrimitive>
const std::vector<bvh_node_t> &BVH<TPrimitive>::nodes() const const std::vector<typename BVH<TPrimitive>::Node> &BVH<TPrimitive>::nodes() const
{ {
return m_nodes; return m_nodes;
} }
...@@ -166,7 +168,7 @@ namespace glare ...@@ -166,7 +168,7 @@ namespace glare
} }
template<typename TPrimitive> template<typename TPrimitive>
void BVH<TPrimitive>::build(std::vector<TPrimitive> &primitives, std::function<glm::vec4(int id)> centroid_from_id, std::function<bvh_node_t(int start, int end)> node_from_range) void BVH<TPrimitive>::build(std::vector<TPrimitive> &primitives, std::function<glm::vec4(int id)> centroid_from_id, std::function<Node(int start, int end)> node_from_range)
{ {
m_centroid_from_id = centroid_from_id; m_centroid_from_id = centroid_from_id;
m_node_from_range = node_from_range; m_node_from_range = node_from_range;
...@@ -240,8 +242,8 @@ namespace glare ...@@ -240,8 +242,8 @@ namespace glare
//inner node //inner node
//pos is the position in which the new ranges will be stored //pos is the position in which the new ranges will be stored
int range_index = m_buffer_position.fetch_add(1); int range_index = m_buffer_position.fetch_add(1);
index_range_t left_range; IndexRange left_range;
index_range_t right_range; IndexRange right_range;
math::Bounds left_centbox; math::Bounds left_centbox;
math::Bounds right_centbox; math::Bounds right_centbox;
...@@ -250,10 +252,10 @@ namespace glare ...@@ -250,10 +252,10 @@ namespace glare
m_kernel_counter.fetch_add(2); m_kernel_counter.fetch_add(2);
// 1. the AABB which contains the range's triangle information is added for later processing (traversal) // 1. the AABB which contains the range's triangle information is added for later processing (traversal)
bvh_node_t node = m_node_from_range(start, end); Node node = m_node_from_range(start, end);
// 0 is the flag for inner node in the node buffer // 0 is the flag for inner node in the node buffer
node.type = BVHNodeType::eInner; node.type = Node::Type::eInner;
// 2. the split plane which causes the least cost is determined by iterating over the 3 axes (since it's axis aligned) // 2. the split plane which causes the least cost is determined by iterating over the 3 axes (since it's axis aligned)
struct { struct {
...@@ -266,7 +268,7 @@ namespace glare ...@@ -266,7 +268,7 @@ namespace glare
for (int axis = 0; axis < 3; ++axis) for (int axis = 0; axis < 3; ++axis)
{ {
bin_t bins[16]; Bin bins[16];
const float cbox_min = centroid_box.min[axis]; const float cbox_min = centroid_box.min[axis];
const float cbox_max = centroid_box.max[axis]; const float cbox_max = centroid_box.max[axis];
const float cbox_diff = cbox_max - cbox_min; const float cbox_diff = cbox_max - cbox_min;
...@@ -289,7 +291,7 @@ namespace glare ...@@ -289,7 +291,7 @@ namespace glare
++(bins[bin_id].object_count); ++(bins[bin_id].object_count);
} }
bin_t left_bounds[15]; Bin left_bounds[15];
//Again, initialize all bounds. //Again, initialize all bounds.
for (int i = 0; i < m_plane_count; ++i) for (int i = 0; i < m_plane_count; ++i)
{ {
...@@ -307,7 +309,7 @@ namespace glare ...@@ -307,7 +309,7 @@ namespace glare
left_bounds[plane].object_count = left_bounds[plane - 1].object_count + bins[plane].object_count; left_bounds[plane].object_count = left_bounds[plane - 1].object_count + bins[plane].object_count;
} }
bin_t right_bounds[15]; Bin right_bounds[15];
//Again and again, initialize bounds. //Again and again, initialize bounds.
for (int i = 0; i < m_plane_count; ++i) for (int i = 0; i < m_plane_count; ++i)
{ {
...@@ -447,8 +449,8 @@ namespace glare ...@@ -447,8 +449,8 @@ namespace glare
} }
else //leaf node else //leaf node
{ {
bvh_node_t node = m_node_from_range(start, end); Node node = m_node_from_range(start, end);
node.type = BVHNodeType::eLeaf; node.type = Node::Type::eLeaf;
node.left_idx = start; node.left_idx = start;
node.right_idx = end; node.right_idx = end;
node.parent = parent; node.parent = parent;
...@@ -481,7 +483,7 @@ namespace glare ...@@ -481,7 +483,7 @@ namespace glare
//if (hit_scene){ //if (hit_scene){
while (hit_scene) while (hit_scene)
{ {
if (m_nodes[current_node].type == BVHNodeType::eInner) //Inner node. if (m_nodes[current_node].type == Node::Type::eInner) //Inner node.
{ {
const int id_left = int(m_nodes[current_node].left_idx); const int id_left = int(m_nodes[current_node].left_idx);
const bool hit_left = intersect::intersects(ray, m_nodes[id_left].bounds, max_distance); const bool hit_left = intersect::intersects(ray, m_nodes[id_left].bounds, max_distance);
......
...@@ -132,7 +132,7 @@ namespace glare ...@@ -132,7 +132,7 @@ namespace glare
return (m_local_collectors[mesh_id]->transform() * glm::vec4(m_local_collectors[mesh_id]->bounds().min.xyz, 1) + return (m_local_collectors[mesh_id]->transform() * glm::vec4(m_local_collectors[mesh_id]->bounds().min.xyz, 1) +
m_local_collectors[mesh_id]->transform() * glm::vec4(m_local_collectors[mesh_id]->bounds().max.xyz, 1)) / 2.f; m_local_collectors[mesh_id]->transform() * glm::vec4(m_local_collectors[mesh_id]->bounds().max.xyz, 1)) / 2.f;
}, [&](int start, int end) { }, [&](int start, int end) {
bvh_node_t node; BVH<unsigned>::Node node;
glm::vec4 best_min = glm::vec4(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), 1.0f); glm::vec4 best_min = glm::vec4(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), 1.0f);
glm::vec4 best_max = glm::vec4(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), 1.0f); glm::vec4 best_max = glm::vec4(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), 1.0f);
node.bounds.min = best_min; node.bounds.min = best_min;
......
...@@ -33,7 +33,7 @@ namespace glare ...@@ -33,7 +33,7 @@ namespace glare
+ vertices[triangle.indices[2]].position) + vertices[triangle.indices[2]].position)
/ 3.f; / 3.f;
}, [&](int start, int end) { }, [&](int start, int end) {
bvh_node_t node; BVH<TriangleIDs>::Node node;
glm::vec4 best_min = glm::vec4(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), 1.0f); glm::vec4 best_min = glm::vec4(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), 1.0f);
glm::vec4 best_max = glm::vec4(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), 1.0f); glm::vec4 best_max = glm::vec4(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), 1.0f);
for (int id = start; id <= end; id++) for (int id = start; id <= end; id++)
......
...@@ -41,19 +41,15 @@ namespace glare ...@@ -41,19 +41,15 @@ namespace glare
Pathtracer::Pathtracer(std::shared_ptr<SceneCollector> collector, RayGeneratorType ray_generator) Pathtracer::Pathtracer(std::shared_ptr<SceneCollector> collector, RayGeneratorType ray_generator)
{ {
m_bounce_count_thresholds[unsigned(EffectType::eDiffuse)] = 4; m_bounce_count_thresholds[unsigned(EffectType::eDiffusion)] = 4;
m_bounce_count_thresholds[unsigned(EffectType::eTranslucent)] = 6;
m_bounce_count_thresholds[unsigned(EffectType::eReflection)] = 6; m_bounce_count_thresholds[unsigned(EffectType::eReflection)] = 6;
m_bounce_count_thresholds[unsigned(EffectType::eRefraction)] = 12; m_bounce_count_thresholds[unsigned(EffectType::eTransmission)] = 12;
m_bounce_count_thresholds[unsigned(EffectType::eTransparent)] = 12; m_bounce_count_thresholds[unsigned(EffectType::eEmission)] = 1;
m_bounce_count_thresholds[unsigned(EffectType::eEmissive)] = 0;
m_ls_bounce_count_thresholds[unsigned(EffectType::eDiffuse)] = 1; m_ls_bounce_count_thresholds[unsigned(EffectType::eDiffusion)] = 1;
m_ls_bounce_count_thresholds[unsigned(EffectType::eTranslucent)] = 3;
m_ls_bounce_count_thresholds[unsigned(EffectType::eReflection)] = 3; m_ls_bounce_count_thresholds[unsigned(EffectType::eReflection)] = 3;
m_ls_bounce_count_thresholds[unsigned(EffectType::eRefraction)] = 6; m_ls_bounce_count_thresholds[unsigned(EffectType::eTransmission)] = 3;
m_ls_bounce_count_thresholds[unsigned(EffectType::eTransparent)] = 8; m_ls_bounce_count_thresholds[unsigned(EffectType::eEmission)] = 6;
m_ls_bounce_count_thresholds[unsigned(EffectType::eEmissive)] = 0;
m_linespace_config.distance_threshold = 8.f; m_linespace_config.distance_threshold = 8.f;
m_render_config.bounces = 16; m_render_config.bounces = 16;
...@@ -84,21 +80,17 @@ namespace glare ...@@ -84,21 +80,17 @@ namespace glare
//bounces //bounces
const auto bounces_child = pt_child.find_child_by_attribute("group", "name", "bounces"); const auto bounces_child = pt_child.find_child_by_attribute("group", "name", "bounces");
m_bounce_count_thresholds[unsigned(EffectType::eDiffuse)] = bounces_child.find_child_by_attribute("item", "name", "diffuse").attribute("value").as_uint(2); m_bounce_count_thresholds[unsigned(EffectType::eDiffusion)] = bounces_child.find_child_by_attribute("item", "name", "diffusion").attribute("value").as_uint(2);
m_bounce_count_thresholds[unsigned(EffectType::eTranslucent)] = bounces_child.find_child_by_attribute("item", "name", "translucent").attribute("value").as_uint(4); m_bounce_count_thresholds[unsigned(EffectType::eReflection)] = bounces_child.find_child_by_attribute("item", "name", "reflection").attribute("value").as_uint(4);
m_bounce_count_thresholds[unsigned(EffectType::eReflection)] = bounces_child.find_child_by_attribute("item", "name", "reflect").attribute("value").as_uint(4); m_bounce_count_thresholds[unsigned(EffectType::eTransmission)] = bounces_child.find_child_by_attribute("item", "name", "transmission").attribute("value").as_uint(4);
m_bounce_count_thresholds[unsigned(EffectType::eRefraction)] = bounces_child.find_child_by_attribute("item", "name", "refract").attribute("value").as_uint(8); m_bounce_count_thresholds[unsigned(EffectType::eEmission)] = bounces_child.find_child_by_attribute("item", "name", "emission").attribute("value").as_uint(8);
m_bounce_count_thresholds[unsigned(EffectType::eTransparent)] = bounces_child.find_child_by_attribute("item", "name", "transparent").attribute("value").as_uint(8);
m_bounce_count_thresholds[unsigned(EffectType::eEmissive)] = bounces_child.find_child_by_attribute("item", "name", "emissive").attribute("value").as_uint(1);
//ls thresholds //ls thresholds
const auto ls_thresholds_child = pt_child.find_child_by_attribute("group", "name", "ls-thresholds"); const auto ls_thresholds_child = pt_child.find_child_by_attribute("group", "name", "ls-thresholds");
m_ls_bounce_count_thresholds[unsigned(EffectType::eDiffuse)] = ls_thresholds_child.find_child_by_attribute("item", "name", "diffuse").attribute("value").as_uint(2); m_ls_bounce_count_thresholds[unsigned(EffectType::eDiffusion)] = ls_thresholds_child.find_child_by_attribute("item", "name", "diffusion").attribute("value").as_uint(2);
m_ls_bounce_count_thresholds[unsigned(EffectType::eTranslucent)] = ls_thresholds_child.find_child_by_attribute("item", "name", "translucent").attribute("value").as_uint(4); m_ls_bounce_count_thresholds[unsigned(EffectType::eReflection)] = ls_thresholds_child.find_child_by_attribute("item", "name", "reflection").attribute("value").as_uint(4);
m_ls_bounce_count_thresholds[unsigned(EffectType::eReflection)] = ls_thresholds_child.find_child_by_attribute("item", "name", "reflect").attribute("value").as_uint(4); m_ls_bounce_count_thresholds[unsigned(EffectType::eTransmission)] = ls_thresholds_child.find_child_by_attribute("item", "name", "transmission").attribute("value").as_uint(4);
m_ls_bounce_count_thresholds[unsigned(EffectType::eRefraction)] = ls_thresholds_child.find_child_by_attribute("item", "name", "refract").attribute("value").as_uint(8); m_ls_bounce_count_thresholds[unsigned(EffectType::eEmission)] = ls_thresholds_child.find_child_by_attribute("item", "name", "emission").attribute("value").as_uint(8);
m_ls_bounce_count_thresholds[unsigned(EffectType::eTransparent)] = ls_thresholds_child.find_child_by_attribute("item", "name", "transparent").attribute("value").as_uint(8);
m_ls_bounce_count_thresholds[unsigned(EffectType::eEmissive)] = ls_thresholds_child.find_child_by_attribute("item", "name", "emissive").attribute("value").as_uint(1);
m_linespace_config.accuracy_threshold = ls_thresholds_child.find_child_by_attribute("item", "name", "accuracy").attribute("value").as_float(0.5f); m_linespace_config.accuracy_threshold = ls_thresholds_child.find_child_by_attribute("item", "name", "accuracy").attribute("value").as_float(0.5f);
m_linespace_config.shadow_threshold = ls_thresholds_child.find_child_by_attribute("item", "name", "shadow").attribute("value").as_float(0.5f); m_linespace_config.shadow_threshold = ls_thresholds_child.find_child_by_attribute("item", "name", "shadow").attribute("value").as_float(0.5f);
...@@ -125,16 +117,16 @@ namespace glare ...@@ -125,16 +117,16 @@ namespace glare
m_render_shader->uniform("u_linespace_properties.distance_threshold", m_linespace_config.distance_threshold); m_render_shader->uniform("u_linespace_properties.distance_threshold", m_linespace_config.distance_threshold);
unsigned bounce_thresholds = 0; unsigned bounce_thresholds = 0;
for (int i = 0; i < 8; ++i) for (int i = 0; i < 4; ++i)
{ {
bounce_thresholds |= (m_bounce_count_thresholds[i] & 0xf) << (4 * i); bounce_thresholds |= (m_bounce_count_thresholds[i] & 0xff) << (8 * i);
} }
m_render_shader->uniform("u_render_config.bounce_thresholds", bounce_thresholds); m_render_shader->uniform("u_render_config.bounce_thresholds", bounce_thresholds);
m_linespace_config.bounce_thresholds = 0; m_linespace_config.bounce_thresholds = 0;
for (int i = 0; i < 8; ++i) for (int i = 0; i < 4; ++i)
{ {
m_linespace_config.bounce_thresholds |= (m_ls_bounce_count_thresholds[i] & 0xf) << (4 * i); m_linespace_config.bounce_thresholds |= (m_ls_bounce_count_thresholds[i] & 0xff) << (8 * i);
} }
m_render_shader->uniform("u_linespace_properties.bounce_thresholds", m_linespace_config.bounce_thresholds); m_render_shader->uniform("u_linespace_properties.bounce_thresholds", m_linespace_config.bounce_thresholds);
......
...@@ -22,12 +22,10 @@ namespace glare ...@@ -22,12 +22,10 @@ namespace glare
enum class EffectType