Commit 26744d31 authored by Johannes Braun's avatar Johannes Braun
Browse files

Switched Material for PBR-like parameter format.

parent 5f0fe266
...@@ -19,29 +19,59 @@ const uint MFLAG_HAS_DISPLACEMENT = 1 << 4; ...@@ -19,29 +19,59 @@ const uint MFLAG_HAS_DISPLACEMENT = 1 << 4;
const uint MFLAG_HAS_TRANSPARENT = 1 << 5; const uint MFLAG_HAS_TRANSPARENT = 1 << 5;
const uint MFLAG_HAS_EMISSIVE = 1 << 6; const uint MFLAG_HAS_EMISSIVE = 1 << 6;
struct ParameterColor
{
vec3 value;
uint texture_available;
sampler2D texture;
uint p[2];
};
struct ParameterFloat
{
float value;
uint texture_available;
sampler2D texture;
};
struct Material struct Material
{ {
vec4 color_diffuse; ParameterColor emission;
vec4 color_ambient; ParameterColor ambient;
vec4 color_emissive; ParameterColor base;
vec4 color_specular;
vec4 color_transparent;
sampler2D map_diffuse;
sampler2D map_ambient;
sampler2D map_specular;
sampler2D map_transparent;
sampler2D map_emissive;
sampler2D map_normal;
sampler2D map_displacement;
float specular_exponent;
float ior;
uint flags; ParameterFloat roughness;
ParameterFloat metallic;
ParameterFloat transmissive;
float misc[3]; float ior;
};
uint p[3];
};
// struct Material
// {
// vec4 color_diffuse;
// vec4 color_ambient;
// vec4 color_emissive;
// vec4 color_specular;
// vec4 color_transparent;
//
// sampler2D map_diffuse;
// sampler2D map_ambient;
// sampler2D map_specular;
// sampler2D map_transparent;
// sampler2D map_emissive;
// sampler2D map_normal;
// sampler2D map_displacement;
//
// float specular_exponent;
// float ior;
//
// uint flags;
//
// float misc[3];
// };
struct BufferLight struct BufferLight
{ {
......
...@@ -100,7 +100,6 @@ bool shade(int id, inout vec3 radiance, uint bounce, out uint bsdf_id) ...@@ -100,7 +100,6 @@ bool shade(int id, inout vec3 radiance, uint bounce, out uint bsdf_id)
//Get Hit data //Get Hit data
Material material; Material material;
Vertex vertex = hit.getVertex(material); Vertex vertex = hit.getVertex(material);
vec4 diffuse = material.getDiffuse(vertex.texcoord);
b_traces[id].properties.travelled_distance += b_traces[id].hit.valid() ? (distance(b_traces[id].ray.origin, vertex.position.xyz)) : FLT_MAX; b_traces[id].properties.travelled_distance += b_traces[id].hit.valid() ? (distance(b_traces[id].ray.origin, vertex.position.xyz)) : FLT_MAX;
......
...@@ -36,15 +36,14 @@ struct BSDFResult ...@@ -36,15 +36,14 @@ struct BSDFResult
struct SampledMaterial struct SampledMaterial
{ {
vec4 diffuse; vec3 base;
vec4 specular; vec3 ambient;
vec4 transparent; vec3 emission;
vec4 emissive;
vec4 ambient; float roughness;
float metallic;
float roughness; // 0..1 float transmission;
float metallic; // 0..1 float ior;
float ior; // 0..n
}; };
vec3 reflectedDirection(vec3 local_hemi_sample, vec3 normal, vec3 reflected, float roughness) vec3 reflectedDirection(vec3 local_hemi_sample, vec3 normal, vec3 reflected, float roughness)
...@@ -55,15 +54,15 @@ vec3 reflectedDirection(vec3 local_hemi_sample, vec3 normal, vec3 reflected, flo ...@@ -55,15 +54,15 @@ vec3 reflectedDirection(vec3 local_hemi_sample, vec3 normal, vec3 reflected, flo
SampledMaterial getMaterialParameters(const in Material material, const in Vertex vertex) SampledMaterial getMaterialParameters(const in Material material, const in Vertex vertex)
{ {
SampledMaterial sampled_material; SampledMaterial sampled_material;
sampled_material.diffuse = material.getDiffuse(vertex.texcoord); sampled_material.base = material.getBase(vertex.texcoord);
sampled_material.specular = material.getSpecular(vertex.texcoord);
sampled_material.transparent = material.getTransparent(vertex.texcoord);
sampled_material.emissive = material.getEmissive(vertex.texcoord);
sampled_material.ambient = material.getAmbient(vertex.texcoord); sampled_material.ambient = material.getAmbient(vertex.texcoord);
sampled_material.emission = material.getEmission(vertex.texcoord);
sampled_material.roughness = material.getRoughness(); sampled_material.roughness = material.getRoughness(vertex.texcoord);
sampled_material.metallic = clamp((sampled_material.specular.r + sampled_material.specular.g + sampled_material.specular.b )/3, 0, 1); sampled_material.metallic = material.getMetallic(vertex.texcoord);
sampled_material.ior = 1.56f;//material.ior; sampled_material.transmission = material.getTransmission(vertex.texcoord);
sampled_material.ior = material.ior;
return sampled_material; return sampled_material;
} }
...@@ -75,9 +74,9 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i ...@@ -75,9 +74,9 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i
//Use the pixel coordinates of the incoming ray. //Use the pixel coordinates of the incoming ray.
result.generated_ray = ray_in; result.generated_ray = ray_in;
if(sampled_material.emissive.rgb != vec3(0)) if(sampled_material.emission.rgb != vec3(0))
{ {
result.radiance = sampled_material.emissive.rgb; result.radiance = sampled_material.emission.rgb;
result.bsdf_id = eEmit; result.bsdf_id = eEmit;
return result; return result;
} }
...@@ -106,7 +105,7 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i ...@@ -106,7 +105,7 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i
float k_s = fresnel; float k_s = fresnel;
float k_rest = 1-k_s; float k_rest = 1-k_s;
float k_t = k_rest * ((sampled_material.transparent.r + sampled_material.transparent.g + sampled_material.transparent.b)/3); float k_t = k_rest * sampled_material.transmission;
float k_d = 1 - k_s - k_t; float k_d = 1 - k_s - k_t;
float roulette_border_specular = k_s; float roulette_border_specular = k_s;
...@@ -116,10 +115,10 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i ...@@ -116,10 +115,10 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i
if(roulette_border_transmit <= random.x) if(roulette_border_transmit <= random.x)
{ {
// Sample lambertian diffuse // Sample lambertian diffuse
result.evaluation = (1-sampled_material.metallic)*sampled_material.diffuse.rgb * ONE_OVER_PI; result.evaluation = (1-sampled_material.metallic)*sampled_material.base * ONE_OVER_PI;
result.generated_ray.direction = normalize(toWorld(randCosineHemisphere(random.x, random.y), incoming, normal)); result.generated_ray.direction = normalize(toWorld(randCosineHemisphere(random.x, random.y), incoming, normal));
result.probability_density = abs(dot(vec4(result.generated_ray.direction, 0), vertex.normal)) * ONE_OVER_PI; result.probability_density = abs(dot(vec4(result.generated_ray.direction, 0), vertex.normal)) * ONE_OVER_PI;
result.radiance = (1-sampled_material.metallic)*sampled_material.diffuse.rgb * ONE_OVER_PI; result.radiance = (1-sampled_material.metallic)*sampled_material.base * ONE_OVER_PI;
result.bsdf_id = eDiffuse; result.bsdf_id = eDiffuse;
// offset by newly generated direction // offset by newly generated direction
result.generated_ray.origin = vertex.position.xyz + 1e-5f * result.generated_ray.direction; result.generated_ray.origin = vertex.position.xyz + 1e-5f * result.generated_ray.direction;
...@@ -137,7 +136,7 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i ...@@ -137,7 +136,7 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i
float geometry_refracted = ggxGeometry(incoming, outgoing_refracted, normal, micro_normal, sampled_material.roughness); float geometry_refracted = ggxGeometry(incoming, outgoing_refracted, normal, micro_normal, sampled_material.roughness);
// Reflections of metallic materials are tinted with the material base color. // Reflections of metallic materials are tinted with the material base color.
vec3 fresnel_tint = fresnelTint(fresnel, sampled_material.metallic, sampled_material.diffuse.rgb); vec3 fresnel_tint = fresnelTint(fresnel, sampled_material.metallic, sampled_material.base);
float n_dot_in = clamp(dot(normal, incoming), 0, 1); float n_dot_in = clamp(dot(normal, incoming), 0, 1);
float n_dot_out = clamp(dot(normal, outgoing_reflected), 0, 1); float n_dot_out = clamp(dot(normal, outgoing_reflected), 0, 1);
...@@ -171,9 +170,9 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i ...@@ -171,9 +170,9 @@ BSDFResult computeBSDF(const in Material material, const in vec2 random, const i
float btdf_denominator = jacobian_refract_denominator; float btdf_denominator = jacobian_refract_denominator;
// Finally, build the brdf. As we do russian roulette, we can just tint the brdf instead of multiplying with the fresnel value. // Finally, build the brdf. As we do russian roulette, we can just tint the brdf instead of multiplying with the fresnel value.
vec3 brdf = mix(vec3(1), sampled_material.diffuse.rgb, sampled_material.metallic) * geometry * hemisphere_sample.distribution / brdf_denominator; vec3 brdf = mix(vec3(1), sampled_material.base, sampled_material.metallic) * geometry * hemisphere_sample.distribution / brdf_denominator;
// Same as above, we don't need the fresnel factor here either. // Same as above, we don't need the fresnel factor here either.
vec3 btdf = (m_dot_in * m_dot_out_refract / (n_dot_in * n_dot_out_refract)) * ior_out_2 * sampled_material.diffuse.rgb * geometry_refracted * hemisphere_sample.distribution / btdf_denominator; vec3 btdf = (m_dot_in * m_dot_out_refract / (n_dot_in * n_dot_out_refract)) * ior_out_2 * sampled_material.base * geometry_refracted * hemisphere_sample.distribution / btdf_denominator;
// russian roulette Part 2 // russian roulette Part 2
// Also check whether the refracted ray is valid, as we don't want to sample with NaN rays. // Also check whether the refracted ray is valid, as we don't want to sample with NaN rays.
......
...@@ -7,34 +7,73 @@ ...@@ -7,34 +7,73 @@
#define mapOrColor(material, color, map, flag, texcoord) (material.color * (((material.flags & flag) == flag) ? texture(material.map, texcoord) : vec4(1))) #define mapOrColor(material, color, map, flag, texcoord) (material.color * (((material.flags & flag) == flag) ? texture(material.map, texcoord) : vec4(1)))
vec4 getDiffuse(const in Material material, const in vec2 texcoord) float texCompMax(const in vec3 vector)
{ {
return material.mapOrColor(color_diffuse, map_diffuse, MFLAG_HAS_DIFFUSE, texcoord); return max(vector.x, max(vector.y, vector.z));
} }
vec4 getSpecular(const in Material material, const in vec2 texcoord) #define getParam3f(parameter, texcoord) (bool(parameter.texture_available) ? texture(parameter.texture, texcoord).rgb : parameter.value)
#define getParam1f(parameter, texcoord) (bool(parameter.texture_available) ? texCompMax(texture(parameter.texture, texcoord).rgb) : parameter.value)
vec3 getBase(const in Material material, const in vec2 texcoord)
{ {
return material.mapOrColor(color_specular, map_specular, MFLAG_HAS_SPECULAR, texcoord); return getParam3f(material.base, texcoord);
} }
vec4 getAmbient(const in Material material, const in vec2 texcoord) vec3 getEmission(const in Material material, const in vec2 texcoord)
{ {
return material.mapOrColor(color_ambient, map_ambient, MFLAG_HAS_AMBIENT, texcoord); return getParam3f(material.emission, texcoord);
} }
vec4 getTransparent(const in Material material, const in vec2 texcoord) vec3 getAmbient(const in Material material, const in vec2 texcoord)
{ {
return material.mapOrColor(color_transparent, map_transparent, MFLAG_HAS_TRANSPARENT, texcoord); return getParam3f(material.ambient, texcoord);
} }
vec4 getEmissive(const in Material material, const in vec2 texcoord) float getRoughness(const in Material material, const in vec2 texcoord)
{ {
return material.mapOrColor(color_emissive, map_emissive, MFLAG_HAS_EMISSIVE, texcoord); return max(getParam1f(material.roughness, texcoord), 0.001f);
} }
float getRoughness(const in Material material) float getMetallic(const in Material material, const in vec2 texcoord)
{ {
return pow(1.f - ((material.specular_exponent.clamp(1, 101)-1)/100.f), 2); return getParam1f(material.metallic, texcoord);
} }
float getTransmission(const in Material material, const in vec2 texcoord)
{
return getParam1f(material.transmissive, texcoord);
}
//
// vec3 getDiffuse(const in Material material, const in vec2 texcoord)
// {
// return material.mapOrColor(color_diffuse, map_diffuse, MFLAG_HAS_DIFFUSE, texcoord);
// }
//
// vec4 getSpecular(const in Material material, const in vec2 texcoord)
// {
// return material.mapOrColor(color_specular, map_specular, MFLAG_HAS_SPECULAR, texcoord);
// }
//
// vec4 getAmbient(const in Material material, const in vec2 texcoord)
// {
// return material.mapOrColor(color_ambient, map_ambient, MFLAG_HAS_AMBIENT, texcoord);
// }
//
// vec4 getTransparent(const in Material material, const in vec2 texcoord)
// {
// return material.mapOrColor(color_transparent, map_transparent, MFLAG_HAS_TRANSPARENT, texcoord);
// }
//
// vec4 getEmissive(const in Material material, const in vec2 texcoord)
// {
// return material.mapOrColor(color_emissive, map_emissive, MFLAG_HAS_EMISSIVE, texcoord);
// }
//
// float getRoughness(const in Material material)
// {
// return pow(1.f - ((material.specular_exponent.clamp(1, 101)-1)/100.f), 2);
// }
#endif //__GL_UTILS_MATERIALS #endif //__GL_UTILS_MATERIALS
...@@ -30,64 +30,64 @@ namespace glare ...@@ -30,64 +30,64 @@ namespace glare
void Material::gui() void Material::gui()
{ {
//ImGui::Begin("Materials");
ImGui::PushID(m_name.c_str()); ImGui::PushID(m_name.c_str());
const static auto colorOption = [](const std::string &name, MaterialParameter3f &param)
{
ImGui::ColorButton(*reinterpret_cast<ImVec4*>(&glm::vec4(param.value, 1)));
ImGui::SameLine();
return ImGui::DragFloat3(name.c_str(), reinterpret_cast<float*>(&param.value), 0.01f, 0.f, 1.f);
};
const static auto floatOption = [](const std::string &name, MaterialParameter1f &param)
{
return ImGui::DragFloat(name.c_str(), &param.value, 0.001f, 0.f, 1.f);
};
bool changed = false; bool changed = false;
ImGui::ColorButton(*reinterpret_cast<ImVec4*>(&glm::vec4(color_diffuse, 1))); changed |= colorOption("Base Color", base);
ImGui::SameLine(); changed |= colorOption("Ambient Color", ambient);
changed |= ImGui::DragFloat3("Diffuse Color", reinterpret_cast<float*>(&color_diffuse), 0.01f, 0, 10000); changed |= colorOption("Emission Color", emission);
ImGui::Spacing();
ImGui::ColorButton(*reinterpret_cast<ImVec4*>(&glm::vec4(color_specular, 1))); changed |= floatOption("Roughness", roughness);
ImGui::SameLine(); changed |= floatOption("Metallic", metallic);
changed |= ImGui::DragFloat3("Specular Color", reinterpret_cast<float*>(&color_specular), 0.01f, 0, 10000); changed |= floatOption("Transmissive", transmissive);
ImGui::Spacing();
ImGui::ColorButton(*reinterpret_cast<ImVec4*>(&glm::vec4(color_transparent, 1))); changed |= ImGui::DragFloat("IOR", &index_of_refraction, 0.001f, 0.1f, 10.f);
ImGui::SameLine();
changed |= ImGui::DragFloat3("Transparent Color", reinterpret_cast<float*>(&color_transparent), 0.01f, 0, 10000); if (changed)
ImGui::ColorButton(*reinterpret_cast<ImVec4*>(&glm::vec4(color_ambient, 1)));
ImGui::SameLine();
changed |= ImGui::DragFloat3("Ambient Color", reinterpret_cast<float*>(&color_ambient), 0.01f, 0, 10000);
ImGui::ColorButton(*reinterpret_cast<ImVec4*>(&glm::vec4(color_emissive, 1)));
ImGui::SameLine();
changed |= ImGui::DragFloat3("Emissive Color", reinterpret_cast<float*>(&color_emissive), 0.01f, 0, 10000);
if (ImGui::DragFloat("Specular Exponent", &specular_exponent, 1.f, 1, 100) || changed)
messaging::Handler::getInstance().submit(tags::material, 1); messaging::Handler::getInstance().submit(tags::material, 1);
ImGui::PopID(); ImGui::PopID();
//ImGui::End();
} }
void Material::activate() const void Material::activate() const
{ {
//TODO: make PBR, remove legacy stuff.
m_shader->use(); m_shader->use();
if (map_diffuse) m_shader->uniform("u_material.map_diffuse", map_diffuse->makeTextureResident()); if (base.texture) m_shader->uniform("u_material.map_diffuse", base.texture->makeTextureResident());
if (map_specular) m_shader->uniform("u_material.map_specular", map_specular->makeTextureResident()); if (ambient.texture) m_shader->uniform("u_material.map_ambient", ambient.texture->makeTextureResident());
if (map_transparent) m_shader->uniform("u_material.map_transparent", map_transparent->makeTextureResident()); if (emission.texture) m_shader->uniform("u_material.has_emissive", emission.texture->makeTextureResident());
if (map_ambient) m_shader->uniform("u_material.map_ambient", map_ambient->makeTextureResident());
if (map_normal) m_shader->uniform("u_material.map_normal", map_normal->makeTextureResident()); if (map_normal) m_shader->uniform("u_material.map_normal", map_normal->makeTextureResident());
if (map_displacement) m_shader->uniform("u_material.map_displacement", map_displacement->makeTextureResident()); if (map_displacement) m_shader->uniform("u_material.map_displacement", map_displacement->makeTextureResident());
if (map_emissive) m_shader->uniform("u_material.has_emissive", map_emissive->makeTextureResident());
m_shader->uniform("u_material.specular_exponent", specular_exponent); m_shader->uniform("u_material.specular_exponent", (1-roughness.value) * 99 + 1); // legacy
m_shader->uniform("u_material.ior", ior); m_shader->uniform("u_material.ior", index_of_refraction);
m_shader->uniform("u_material.color_diffuse", color_diffuse); m_shader->uniform("u_material.color_diffuse", base.value);
m_shader->uniform("u_material.color_ambient", color_ambient); m_shader->uniform("u_material.color_ambient", ambient.value);
m_shader->uniform("u_material.color_specular", color_specular); m_shader->uniform("u_material.color_specular", glm::vec3(1, 1, 1));
m_shader->uniform("u_material.color_transparent", color_transparent); m_shader->uniform("u_material.color_transparent", glm::vec3(0, 0, 0));
m_shader->uniform("u_material.color_emissive", color_emissive); m_shader->uniform("u_material.color_emissive", emission.value);
m_shader->uniform("u_material.has_diffuse", bool(map_diffuse)); m_shader->uniform("u_material.has_diffuse", bool(base.texture));
m_shader->uniform("u_material.has_ambient", bool(map_ambient)); m_shader->uniform("u_material.has_ambient", bool(ambient.texture));
m_shader->uniform("u_material.has_specular", bool(map_specular)); m_shader->uniform("u_material.has_specular", false);
m_shader->uniform("u_material.has_transparent", bool(map_transparent)); m_shader->uniform("u_material.has_transparent", false);
m_shader->uniform("u_material.has_normal", bool(map_normal)); m_shader->uniform("u_material.has_normal", bool(map_normal));
m_shader->uniform("u_material.has_displacement", bool(map_displacement)); m_shader->uniform("u_material.has_displacement", bool(map_displacement));
m_shader->uniform("u_material.has_emissive", bool(map_emissive)); m_shader->uniform("u_material.has_emissive", bool(emission.texture));
m_shader->uniform("u_camera_position", glm::vec3(state::camera->getOwner()->absoluteTransform() * glm::vec4(0, 0, 0, 1))); m_shader->uniform("u_camera_position", glm::vec3(state::camera->getOwner()->absoluteTransform() * glm::vec4(0, 0, 0, 1)));
} }
......
...@@ -15,6 +15,18 @@ namespace glare ...@@ -15,6 +15,18 @@ namespace glare
{ {
namespace core namespace core
{ {
struct MaterialParameter1f
{
float value;
std::shared_ptr<TextureRGBA_UB> texture;
};
struct MaterialParameter3f
{
glm::vec3 value;
std::shared_ptr<TextureRGBA_UB> texture;
};
class Material class Material
{ {
public: public:
...@@ -30,23 +42,18 @@ namespace glare ...@@ -30,23 +42,18 @@ namespace glare
std::shared_ptr<Program> getShader() const; std::shared_ptr<Program> getShader() const;
float specular_exponent = 100; MaterialParameter3f emission = { glm::vec3(0) };
MaterialParameter3f ambient = { glm::vec3(0) };
MaterialParameter3f base = { glm::vec3(1) };
glm::vec3 color_diffuse = glm::vec3(0); MaterialParameter1f roughness = { 0 };
glm::vec3 color_ambient = glm::vec3(0); MaterialParameter1f metallic = { 0 };
glm::vec3 color_specular = glm::vec3(0); MaterialParameter1f transmissive = { 0 };
glm::vec3 color_transparent = glm::vec3(0);
glm::vec3 color_emissive = glm::vec3(0);
std::shared_ptr<TextureRGBA_UB> map_ambient; float index_of_refraction = 1.45f;
std::shared_ptr<TextureRGBA_UB> map_diffuse;
std::shared_ptr<TextureRGBA_UB> map_specular;
std::shared_ptr<TextureRGBA_UB> map_transparent;
std::shared_ptr<TextureRGBA_UB> map_emissive;
std::shared_ptr<TextureRGBA_UB> map_normal; std::shared_ptr<TextureRGBA_UB> map_normal;
std::shared_ptr<TextureRGBA_UB> map_displacement; std::shared_ptr<TextureRGBA_UB> map_displacement;
float ior;
private: private:
static std::atomic<size_t> m_current_id; static std::atomic<size_t> m_current_id;
const size_t m_material_id; const size_t m_material_id;
......
...@@ -216,7 +216,7 @@ namespace glare ...@@ -216,7 +216,7 @@ namespace glare
{ {
auto mesh_spt = mesh_mat.mesh; auto mesh_spt = mesh_mat.mesh;
std::shared_ptr<core::GraphNode> mesh_node = std::make_shared<core::GraphNode>(sub.attribute("url").as_string()); std::shared_ptr<core::GraphNode> mesh_node = std::make_shared<core::GraphNode>(sub.attribute("url").as_string());
mesh_node->addComponent(std::make_shared<core::MeshRenderer>(mesh_spt, data->materials["qeng_coll_default_material"])); mesh_node->addComponent(std::make_shared<core::MeshRenderer>(mesh_spt, data->materials["__collada_default_material__"]));
root->attach(mesh_node); root->attach(mesh_node);
} }
continue; continue;
...@@ -441,7 +441,7 @@ namespace glare ...@@ -441,7 +441,7 @@ namespace glare
if (material_name == "") if (material_name == "")
{ {
material_name = "qeng_coll_default_material"; material_name = "__collada_default_material__";
} }
const auto &positions = sources[vertices_id]; const auto &positions = sources[vertices_id];
...@@ -544,11 +544,7 @@ namespace glare ...@@ -544,11 +544,7 @@ namespace glare
void Collada::decodeMaterialsNode(const pugi::xml_node& mat_node) const void Collada::decodeMaterialsNode(const pugi::xml_node& mat_node) const
{ {
//Add a default material. //Add a default material.
auto default_material = std::make_shared<core::Material>("qeng_coll_default_material"); data->materials.emplace("__collada_default_material__", std::make_shared<core::Material>("__collada_default_material__"));
default_material->color_diffuse = color::preset::white.rgb;
default_material->ior = 1.0;
default_material->specular_exponent = 1;
data->materials.emplace("qeng_coll_default_material", default_material);
for (const auto &mat_sub : mat_node.children()) for (const auto &mat_sub : mat_node.children())
{ {
...@@ -561,22 +557,25 @@ namespace glare ...@@ -561,22 +557,25 @@ namespace glare
auto material = std::make_shared<core::Material>(mat_name); auto material = std::make_shared<core::Material>(mat_name);
material->color_diffuse = glm::vec3(effect->diffuse); material->base.value = glm::vec3(effect->diffuse);
material->color_ambient = glm::vec3(effect->ambient); material->ambient.value = glm::vec3(effect->ambient);
material->color_specular = glm::vec3(effect->specular); material->emission.value = glm::vec3(effect->emission);
material->color_transparent = glm::vec3(effect->transparent);
material->color_emissive = glm::vec3(effect->emission);
material->specular_exponent = effect->shininess; material->metallic.value = glm::max(glm::compMax(glm::vec3(effect->reflective)), effect->reflectivity);
material->ior = effect->ior; material->roughness.value = 1 - glm::compMax(glm::vec3(effect->specular));
material->transmissive.value = glm::compMax(glm::vec3(effect->transparent));