transparency 50% in red for mesh

Problems building or running the engine, queries about how to use features etc.
Post Reply
mgs_oleg
Gnoblar
Posts: 20
Joined: Fri Mar 30, 2018 8:24 pm
x 1

transparency 50% in red for mesh

Post by mgs_oleg »

Hi All,


I've jusr created model in blender and set to it proper texture mapping, the png file itself transparent only borders of that can be seen.
What I need to do now is just to set red color of my mesh but make it 50% transparent.
Here is my material file

Code: Select all

// ProperMaterial generated by blender2ogre 2018-04-13 23:53:50.273294

material ProperMaterial {
    receive_shadows on
    technique {
        pass ProperMaterial {
            ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0
            diffuse 0.6400000190734865 0.6400000190734865 0.6400000190734865 1.0
            specular 0.5 0.5 0.5 1.0 12.5
            emissive 0.0 0.0 0.0 1.0
            
            alpha_to_coverage off 
            colour_write on 
            cull_hardware clockwise 
            depth_check on 
            depth_func less_equal 
            depth_write on 
            illumination_stage  
            light_clip_planes off 
            light_scissor off 
            lighting on 
            normalise_normals off 
            polygon_mode solid 
            scene_blend one zero 
            scene_blend_op add 
            shading gouraud 
            transparent_sorting on 

            texture_unit  {
                texture proper.png 
                tex_address_mode wrap 
                scale 1.0 1.0 
                colour_op modulate 
            }
        }
    }
} 
I've tried to change it (based on info I've got from web site or google...), but not really got what I want
Could someone help me here ?
hyyou
Gremlin
Posts: 173
Joined: Wed Feb 03, 2016 2:24 am
x 17
Contact:

Re: transparency 50% in red for mesh

Post by hyyou »

Probably a little off-topic, but did you try Ogre 2.1?
Ogre 2.1's HLMS provide less obscure way to access material setting.
It may be just my own opinion.
mgs_oleg
Gnoblar
Posts: 20
Joined: Fri Mar 30, 2018 8:24 pm
x 1

Re: transparency 50% in red for mesh

Post by mgs_oleg »

Hi,
I did not.
how to change it there then ?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: transparency 50% in red for mesh

Post by paroj »

use:
scene_blend alpha_blend

in blender:

Image
mgs_oleg
Gnoblar
Posts: 20
Joined: Fri Mar 30, 2018 8:24 pm
x 1

Re: transparency 50% in red for mesh

Post by mgs_oleg »

thanks for reply paroj,

Here what I have in blender (and actually what I need in ogre: only borders are strong green lines configured as texture, and box itself has to be transparent with any color I need during runtime )

Image

but that is what I am actually getting (hopefully you will recognize this darkness )


Image

and this is my material

Code: Select all

// ProperMaterial generated by blender2ogre 2018-04-14 14:39:25.441265

material ProperMaterial {
    receive_shadows on
    technique {
        pass ProperMaterial {
            ambient 0.8000000715255737 0.03943429887294769 0.000733385153580457 0.7939394116401672
            diffuse 0.8000000715255737 0.03943429887294769 0.000733385153580457 0.7939394116401672
            specular 1.0 0.0 0.003955117892473936 0.7939394116401672 12.5
            emissive 1.6000001430511475 0.07886859774589539 0.001466770307160914 0.7939394116401672
            
            alpha_to_coverage off 
            colour_write on 
            cull_hardware clockwise 
            depth_check on 
            depth_func less_equal 
            depth_write on 
            illumination_stage  
            light_clip_planes off 
            light_scissor off 
            lighting on 
            normalise_normals off 
            polygon_mode solid 
            scene_blend alpha_blend 
            scene_blend_op add 
            shading gouraud 
            transparent_sorting on 

            texture_unit  {
                texture proper.png 
                tex_address_mode wrap 
                scale 1.0 1.0 
                colour_op modulate 
            }
        }
    }
} 
and my code (maybe something wrong here, its just tutorial one )

Code: Select all

    // do not forget to call the base first
    OgreBites::ApplicationContext::setup();
    
    // register for input events
    addInputListener(this);

    // get a pointer to the already created root
    Ogre::Root* root = getRoot();
    Ogre::SceneManager* scnMgr = root->createSceneManager();

    // register our scene with the RTSS
    Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
    shadergen->addSceneManager(scnMgr);

    // without light we would just get a black screen    
    Ogre::Light* light = scnMgr->createLight("MainLight");
    Ogre::SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    lightNode->setPosition(0, 50, 15);
    lightNode->attachObject(light);

    // also need to tell where we are
    Ogre::SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    camNode->setPosition(0, 0, 0);
    camNode->lookAt(Ogre::Vector3(0, 0, -20), Ogre::Node::TS_PARENT);

    // create the camera
    Ogre::Camera* cam = scnMgr->createCamera("myCam");
    cam->setNearClipDistance(5); // specific to this sample
    cam->setAutoAspectRatio(true);
    camNode->attachObject(cam);

    // and tell it to render into the main window
    getRenderWindow()->addViewport(cam);

    // finally something to render
    Ogre::Entity* ent = scnMgr->createEntity("ProperCube.mesh");
    Ogre::SceneNode* node = scnMgr->getRootSceneNode()->createChildSceneNode();
	
	//node->scale(1, 1, 3);
	
	node->setPosition(0, 0, -20);
	Ogre::Real r = 125;
	node->roll(Ogre::Radian(r));
	node->yaw(Ogre::Radian(r));
	//node->pitch(Ogre::Radian(45));
	node->attachObject(ent);
	//
what do you think I have to do ?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: transparency 50% in red for mesh

Post by paroj »

colour_op modulate

means that it multiplies the texture colour with the material colour. e.g. texture transparent black (0, 0, 0, 0), by material opaque red (1, 0, 0, 1) becomes transparent black (0, 0, 0, 0). Which is exactly what you see.
mgs_oleg
Gnoblar
Posts: 20
Joined: Fri Mar 30, 2018 8:24 pm
x 1

Re: transparency 50% in red for mesh

Post by mgs_oleg »

thanks paroj for answering - so what I have to change in this case ?
Post Reply