Blender2Ogre: default value Alpha = 1.0 is wrong?

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
ManVsOgre
Gnoblar
Posts: 7
Joined: Thu Jan 18, 2018 3:58 pm

Blender2Ogre: default value Alpha = 1.0 is wrong?

Post by ManVsOgre »

Hallo,

i am not sure, but i think i found a bug in the blender2ogre addon https://github.com/OGRECave/blender2ogre.
If blender2ogre is exporting a *.mesh and .*material from Blender with mat.use_transparency = false, it is generating this material file.

Code: Select all

// N genrated by blender2ogre 0.5.8
material N 
{
    technique
    {
        pass N
        {
            ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0
            diffuse 0.800000011920929 0.800000011920929 0.800000011920929 1.0
            specular 0.5 0.5 0.5 1.0 12.5
            emissive 0.0 0.0 0.0 1.0
            texture_unit 
            {
                texture Ampel_col.jpg
            }
        }
    }
}
Alpha is set to 1.0!
In OGRE Alpha = 0.0 means 0% transparent
In Blender Alpha = 0.0 means 100% transparent
https://docs.blender.org/manual/en/late ... rency.html

If mat.use_transparency = false, then Blenders Alpha is 1.0 (0% transparent). But blender2ogre is setting Ogre Alpha to 1.0 (100% transparent).
I looked at the material.py from the current default/master (Revision 305) from https://github.com/OGRECave/blender2ogre.
There you can see, that the default value is set to alpha = 1.0. It should be alpha = 0.0.
Am i right?

material.py

Code: Select all

 with self.w.embed():
            color = mat.diffuse_color
            alpha = 1.0
            if mat.use_transparency:
                alpha = mat.alpha

            slots = get_image_textures( mat )        # returns texture_slot objects (CLASSIC MATERIAL)
            usealpha = False #mat.ogre_depth_write
            for slot in slots:
                #if slot.use_map_alpha and slot.texture.use_alpha: usealpha = True; break
                if (slot.texture.image is not None) and (slot.texture.image.use_alpha): usealpha = True; break

            ## force material alpha to 1.0 if textures use_alpha?
            #if usealpha: alpha = 1.0    # let the alpha of the texture control material alpha?

            self.w.iline('lighting %s' % ('off' if mat.use_shadeless else 'on'))

            if mat.use_fixed_pipeline and not mat.use_shadeless:
                f = mat.ambient
                if mat.use_vertex_color_paint:
                    self.w.iline('ambient vertexcolour' )
                else:        # fall back to basic material
                    self.w.iline('ambient %s %s %s %s' %(color.r*f, color.g*f, color.b*f, alpha) )

                f = mat.diffuse_intensity
                if mat.use_vertex_color_paint:
                    self.w.iline('diffuse vertexcolour' )
                else:        # fall back to basic material
                    self.w.iline('diffuse %s %s %s %s' %(color.r*f, color.g*f, color.b*f, alpha) )

                f = mat.specular_intensity
                s = mat.specular_color
                self.w.iline('specular %s %s %s %s %s' %(s.r*f, s.g*f, s.b*f, alpha, mat.specular_hardness/4.0) )

                f = mat.emit
                if mat.use_shadeless:     # requested by Borris
                    self.w.iline('emissive %s %s %s 1.0' %(color.r, color.g, color.b) )
                elif mat.use_vertex_color_light:
                    self.w.iline('emissive vertexcolour' )
                else:
                    self.w.iline('emissive %s %s %s %s' %(color.r*f, color.g*f, color.b*f, alpha) )
                self.w.iline('')
paroj
OGRE Team Member
OGRE Team Member
Posts: 2141
Joined: Sun Mar 30, 2014 2:51 pm
x 1151

Re: Blender2Ogre: default value Alpha = 1.0 is wrong?

Post by paroj »

no, ogre alpha is the same as blender alpha
ManVsOgre
Gnoblar
Posts: 7
Joined: Thu Jan 18, 2018 3:58 pm

Re: Blender2Ogre: default value Alpha = 1.0 is wrong?

Post by ManVsOgre »

My Fault :oops: . Thank you for your reply