forked from bartvdbraak/blender
[#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.
This commit is contained in:
parent
e5eed21a6b
commit
f78e11dc38
@ -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) {
|
||||
|
@ -61,6 +61,10 @@ private:
|
||||
/** Fills the array of mtex indices which have image. Used for exporting images. */
|
||||
void createTextureIndices(Material *ma, std::vector<int> &indices);
|
||||
|
||||
void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void writeLambert(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void writePhong(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
|
||||
bool hasEffects(Scene *sce);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user