diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2015-03-05 20:44:04 +0300 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2015-03-05 20:44:04 +0300 |
commit | 04b0a9f4b885e8e3b0b3207f3b3cda74b936df3e (patch) | |
tree | 30f71912565f7084245503713393ef29523af940 /source/blender/collada/DocumentImporter.cpp | |
parent | 23af8984bb6be579115a4b0e81b65f8cb5a31e83 (diff) |
COLLADA - support for shadeless material (SHADER_CONSTANT)
This patch make it possible to export and import shadeless material.
Reviewers: sergey, sauraedron
Subscribers: sergey
Projects: #collada
Differential Revision: https://developer.blender.org/D1094
Diffstat (limited to 'source/blender/collada/DocumentImporter.cpp')
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 462b7b6f200..655e01a6dad 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -800,10 +800,13 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) { ma->diff_shader = MA_DIFF_LAMBERT; } + else if (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) { + ma->mode = MA_SHLESS; + } // default - lambert else { ma->diff_shader = MA_DIFF_LAMBERT; - fprintf(stderr, "Current shader type is not supported, default to lambert.\n"); + fprintf(stderr, "Shader type %d is not supported, default to lambert.\n", shader); } // reflectivity ma->ray_mirror = ef->getReflectivity().getFloatValue(); @@ -899,7 +902,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia COLLADAFW::Texture ctex = ef->getEmission().getTexture(); mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); if (mtex != NULL) { - mtex->mapto = MAP_EMIT; + mtex->mapto = (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) ? MAP_COL : MAP_EMIT; i++; } } @@ -930,6 +933,21 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia } } #endif + +/** + * <constant> cannot have diffuse, ambient, specular, shininnes as its child. + * So color is solely based on + * the emission color, so we map emission color to material's color + */ + if (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) { + COLLADAFW::Color col_emmission; + if (ef->getEmission().isValid()) { + col_emmission = ef->getEmission().getColor(); + ma->r = col_emmission.getRed(); + ma->g = col_emmission.getGreen(); + ma->b = col_emmission.getBlue(); + } + } material_texture_mapping_map[ma] = texindex_texarray_map; } |