diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2015-03-05 21:33:59 +0300 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2015-03-05 21:44:23 +0300 |
commit | 37d7b2d3b620bcd9dc5d0c5e6aa99968c5bb51ef (patch) | |
tree | 5ba73cfb926acad327b655dfab9cf919365bd103 /source/blender/collada | |
parent | e2d4a93a008429ecd95a65a08bb48edfc6fdd305 (diff) |
Revert "COLLADA - support for shadeless material (SHADER_CONSTANT)"
This reverts commit 04b0a9f4b885e8e3b0b3207f3b3cda74b936df3e.
Diffstat (limited to 'source/blender/collada')
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 22 | ||||
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 73 |
2 files changed, 28 insertions, 67 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 655e01a6dad..462b7b6f200 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -800,13 +800,10 @@ 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, "Shader type %d is not supported, default to lambert.\n", shader); + fprintf(stderr, "Current shader type is not supported, default to lambert.\n"); } // reflectivity ma->ray_mirror = ef->getReflectivity().getFloatValue(); @@ -902,7 +899,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 = (shader == COLLADAFW::EffectCommon::SHADER_CONSTANT) ? MAP_COL : MAP_EMIT; + mtex->mapto = MAP_EMIT; i++; } } @@ -933,21 +930,6 @@ 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; } diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index f0ef0cb7c20..13dc1eda580 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -173,44 +173,37 @@ void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep, void EffectsExporter::operator()(Material *ma, Object *ob) { - bool is_shadeless = ma->mode & MA_SHLESS; // create a list of indices to textures of type TEX_IMAGE std::vector<int> tex_indices; if (this->export_settings->include_material_textures) createTextureIndices(ma, tex_indices); openEffect(translate_id(id_name(ma)) + "-effect"); - + COLLADASW::EffectProfile ep(mSW); ep.setProfileType(COLLADASW::EffectProfile::COMMON); ep.openProfile(); - - /* set shader type */ - if (is_shadeless) { - ep.setShaderType(COLLADASW::EffectProfile::CONSTANT); + // set shader type - one of three blinn, phong or lambert + if (ma->spec > 0.0f) { + if (ma->spec_shader == MA_SPEC_BLINN) { + writeBlinn(ep, ma); + } + else { + // \todo figure out handling of all spec+diff shader combos blender has, for now write phong + // for now set phong in case spec shader is not blinn + writePhong(ep, ma); + } } else { - if (ma->spec > 0.0f) { - if (ma->spec_shader == MA_SPEC_BLINN) { - writeBlinn(ep, ma); - } - else { - // \todo figure out handling of all spec+diff shader combos blender has, for now write phong - // for now set phong in case spec shader is not blinn - writePhong(ep, ma); - } + if (ma->diff_shader == MA_DIFF_LAMBERT) { + writeLambert(ep, ma); } else { - if (ma->diff_shader == MA_DIFF_LAMBERT) { - writeLambert(ep, ma); - } - else { - // \todo figure out handling of all spec+diff shader combos blender has, for now write phong - writePhong(ep, ma); - } + // \todo figure out handling of all spec+diff shader combos blender has, for now write phong + writePhong(ep, ma); } } - + // index of refraction if (ma->mode & MA_RAYTRANSP) { ep.setIndexOfRefraction(ma->ang, false, "index_of_refraction"); @@ -223,40 +216,28 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // transparency if (ma->mode & MA_TRANSP) { - // Todo: because we are in A_ONE mode transparency is calculated like this: + // Tod: because we are in A_ONE mode transparency is calculated like this: ep.setTransparency(ma->alpha, false, "transparency"); // cot = getcol(1.0f, 1.0f, 1.0f, 1.0f); // ep.setTransparent(cot); } // emission - if (is_shadeless) { - cot = getcol(ma->r, ma->g, ma->b, 1.0f); - } - else { - cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f); - } + cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f); ep.setEmission(cot, false, "emission"); // diffuse multiplied by diffuse intensity - if (!is_shadeless) { - cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f); - ep.setDiffuse(cot, false, "diffuse"); - } - + cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f); + ep.setDiffuse(cot, false, "diffuse"); // ambient /* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */ - if (is_shadeless) + if (this->scene->world) + cot = getcol(this->scene->world->ambr * ma->amb, this->scene->world->ambg * ma->amb, this->scene->world->ambb * ma->amb, 1.0f); + else cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f); - else { - if (this->scene->world) - cot = getcol(this->scene->world->ambr * ma->amb, - this->scene->world->ambg * ma->amb, - this->scene->world->ambb * ma->amb, 1.0f); - ep.setAmbient(cot, false, "ambient"); - } + ep.setAmbient(cot, false, "ambient"); // reflective, reflectivity if (ma->mode & MA_RAYMIRROR) { @@ -272,10 +253,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // specular if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) { - if (!is_shadeless) { - cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f); - ep.setSpecular(cot, false, "specular"); - } + cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f); + ep.setSpecular(cot, false, "specular"); } // XXX make this more readable if possible |