diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2019-06-04 15:31:22 +0300 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2019-06-05 13:42:54 +0300 |
commit | eda377c223cfc0460e3294c95771313f8d4388c3 (patch) | |
tree | d8c7d5d74a74f19b993ad18f09d098f5ed039549 /source/blender/collada/EffectExporter.cpp | |
parent | 98cea7edcefa58d5eb7e2350461b8efe33fe7d9e (diff) |
update Collada Importer: reworked export and import of Materials
- added import of transparency and emission into principled BSDF Shader
- added support for importing all default collada material parameters
* diffuse
* emission
* index_of_refraction
* shininess (mapped to BSDF Roughness)
* reflectivity (mapped to BSDF Metallic)
* transparency + transparent mapped to BSDF Alpha)
* ambient (creates unconnected texture node)
* specular (creates unconnected texture node)
* reflective(creates unconnected texture node)
- added support for exporting collada material parameters:
* diffuse
* emission
* index_of_refraction
* shininess (mapped to BSDF Roughness)
* reflectivity (mapped to BSDF Metallic)
* transparency + transparent mapped to BSDF Alpha)
- prepared support for exporting the following parameters
but currently commented out:
* ambient (creates unconnected texture node)
* specular (creates unconnected texture node)
* reflective(creates unconnected texture node)
Problem: For now we only allow export of principled BSDF based
materials. I am not sure from where to get ambient, specular
and reflective as those values are not included in the
principled BSDF Shader (wip).
Diffstat (limited to 'source/blender/collada/EffectExporter.cpp')
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index a45cdccecf3..a0ad3740e45 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -104,6 +104,7 @@ void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep, Material *m double alpha = bc_get_alpha(ma); ep.setTransparency(alpha, false, "alpha"); } + void EffectsExporter::set_diffuse_color(COLLADASW::EffectProfile &ep, Material *ma) { // get diffuse color @@ -111,6 +112,25 @@ void EffectsExporter::set_diffuse_color(COLLADASW::EffectProfile &ep, Material * ep.setDiffuse(cot, false, "diffuse"); } +void EffectsExporter::set_ambient(COLLADASW::EffectProfile &ep, Material *ma) +{ + // get diffuse color + COLLADASW::ColorOrTexture cot = bc_get_ambient(ma); + ep.setAmbient(cot, false, "ambient"); +} +void EffectsExporter::set_specular(COLLADASW::EffectProfile &ep, Material *ma) +{ + // get diffuse color + COLLADASW::ColorOrTexture cot = bc_get_specular(ma); + ep.setSpecular(cot, false, "specular"); +} +void EffectsExporter::set_reflective(COLLADASW::EffectProfile &ep, Material *ma) +{ + // get diffuse color + COLLADASW::ColorOrTexture cot = bc_get_reflective(ma); + ep.setReflective(cot, false, "reflective"); +} + void EffectsExporter::set_reflectivity(COLLADASW::EffectProfile &ep, Material *ma) { double reflectivity = bc_get_reflectivity(ma); @@ -123,6 +143,18 @@ void EffectsExporter::set_emission(COLLADASW::EffectProfile &ep, Material *ma) ep.setEmission(cot, false, "emission"); } +void EffectsExporter::set_ior(COLLADASW::EffectProfile &ep, Material *ma) +{ + double alpha = bc_get_ior(ma); + ep.setIndexOfRefraction(alpha, false, "ior"); +} + +void EffectsExporter::set_shininess(COLLADASW::EffectProfile &ep, Material *ma) +{ + double shininess = bc_get_shininess(ma); + ep.setShininess(shininess, false, "shininess"); +} + void EffectsExporter::get_images(Material *ma, KeyImageMap &material_image_map) { if (!ma->use_nodes) { @@ -180,10 +212,17 @@ void EffectsExporter::operator()(Material *ma, Object *ob) COLLADASW::ColorOrTexture cot; - set_transparency(ep, ma); set_diffuse_color(ep, ma); - set_reflectivity(ep, ma); set_emission(ep, ma); + set_ior(ep, ma); + set_shininess(ep, ma); + set_reflectivity(ep, ma); + set_transparency(ep, ma); + + /* TODO: from where to get ambient, specular and reflective? */ + // set_ambient(ep, ma); + // set_specular(ep, ma); + // set_reflective(ep, ma); get_images(ma, material_image_map); std::string active_uv(getActiveUVLayerName(ob)); |