diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-22 18:28:56 +0300 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-22 18:28:56 +0300 |
commit | f78e11dc3888f6d0e3c4b3ea86ca29c9f142e3bf (patch) | |
tree | a438a2ecec9012bc8584afcb43fac9336bf4b2a9 /source/blender/collada/EffectExporter.cpp | |
parent | e5eed21a6bf9d8ab36f72d51c3d9f6fad02e795e (diff) |
[#26476] <specular> and <shininess> missing from Colada
reported by Juan Linietsky
Export <specular> for <phong> and <blinn> shaders, <shininess> was already being written for these.
<lambert> shader doesn't have <shininess>.
Right now we write <phong> when blender spec is phong, <blinn> when blender spec is blinn. When spec is
any other shader, and diffuse shader set to lambert, we export as <lambert>. Any other combination defaults
right now to <phong>. This will change when Blender specific profiles have been created for the shader
combinations in Blender.
Diffstat (limited to 'source/blender/collada/EffectExporter.cpp')
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 323b90fe1cc..085ee7356ab 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -89,6 +89,34 @@ void EffectsExporter::exportEffects(Scene *sce) } } +void EffectsExporter::writeBlinn(COLLADASW::EffectProfile &ep, Material *ma) +{ + COLLADASW::ColorOrTexture cot; + ep.setShaderType(COLLADASW::EffectProfile::BLINN); + // shininess + ep.setShininess(ma->har); + // specular + cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); + ep.setSpecular(cot); +} + +void EffectsExporter::writeLambert(COLLADASW::EffectProfile &ep, Material *ma) +{ + COLLADASW::ColorOrTexture cot; + ep.setShaderType(COLLADASW::EffectProfile::LAMBERT); +} + +void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma) +{ + COLLADASW::ColorOrTexture cot; + ep.setShaderType(COLLADASW::EffectProfile::PHONG); + // shininess + ep.setShininess(ma->har); + // specular + cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); + ep.setSpecular(cot); +} + void EffectsExporter::operator()(Material *ma, Object *ob) { // create a list of indices to textures of type TEX_IMAGE @@ -102,18 +130,17 @@ void EffectsExporter::operator()(Material *ma, Object *ob) ep.openProfile(); // set shader type - one of three blinn, phong or lambert if (ma->spec_shader == MA_SPEC_BLINN) { - ep.setShaderType(COLLADASW::EffectProfile::BLINN); - // shininess - ep.setShininess(ma->har); + writeBlinn(ep, ma); } else if (ma->spec_shader == MA_SPEC_PHONG) { - ep.setShaderType(COLLADASW::EffectProfile::PHONG); - // shininess - ep.setShininess(ma->har); + writePhong(ep, ma); + } + else if(ma->diff_shader == MA_DIFF_LAMBERT) { + writeLambert(ep, ma); } else { - // XXX write warning "Current shader type is not supported" - ep.setShaderType(COLLADASW::EffectProfile::LAMBERT); + // \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) { |