Tagged: material Toggle Comment Threads | Keyboard Shortcuts

  • frankiezafe 21:10 on 2017-02-22 Permalink | Reply
    Tags: , , material,   

    Several hours of work later, the class PMaterial is fully integrated to PNode. This part has been tricky: materials and textures are shared objects, managed by managers below the objects.

    The approach is to create PMaterial on demand, when you call pnode.getMaterial, for instance. Once created, it stays in the pnode until you destroy it or overwrite the material with another.

    This limits the memory consumption and force the coder to always retrieve the material pointer from the pnode, and not to store it.

    Another cool feature of the pnode.getMaterial is that the material can be created RT if the mesh doesn’t specify one.

    On the PMaterial level, it is becoming very easy to add the methods to access the different layers of the Ogre material.

    For instance, here is the code used to create the 2 materials applied on the balls in the image above:

    pmat_even.create( "Test", "Nice material" );
    pmat_even.diffuse( 1, 0, 0 );
    // activation of fog
    pmat_even.fogMode( Ogre::FOG_EXP );
    pmat_even.fogDensity( 0.1 );
    pmat_even.fogDistance( 10, 15 );
    pmat_even.fogColor( 0.4, 0.4, 0.4 ); // same as background
    // cloning pmat_even in pmat_odd
    pmat_odd.clone( &pmat_even );
    pmat_odd.fogColor( 0.8, 0.8, 0.8 );
    pmat_odd.shading( Ogre::SO_FLAT );
    // adding a pass on the material
    pmat_odd.addPass();
    // there are now 2 passes in technique 0 of this material
    uint tid = 0;
    uint pid = 1;
    pmat_odd.emissive( 1,0,1, tid,pid );
    pmat_odd.shading( Ogre::SO_FLAT, tid,pid );
    pmat_odd.polygon( Ogre::PM_WIREFRAME, tid,pid );
    

    It’s super easy to clone a material, at creation or via the clone method. The second pass of the odd material have to be set manually. Passes are not cloneable (yet?).

    As you may notice, mentioning the technique or pass to attack is optional. If your material has only one technique and one pass, the call is very short. Once you beginning to build a more complex material, adding 2 uint at the end of your arguments should not be too difficult…

    The material of the cube is also created manually:

    PMaterial pmat2( pmat_even );
    // disabling the fog
    pmat2.fogMode( Ogre::FOG_NONE );
    pmat2.diffuse( 1, 1, 1 );
    // checking the number of textures
    if ( pmat2.getTextureUnitCount( ) == 0 ) {
    	// adding one 
    	pmat2.addTexture( "General", "child-computer.jpg" );
    } else {
    	// modifying the first one
    	pmat2.setTexture( "General", "child-computer.jpg" );
    }
    cube.material( &pmat2, true );
    

    More, soon!

     
  • frankiezafe 17:33 on 2017-01-12 Permalink | Reply
    Tags: , , , material, ,   

    screenshot01122017_171204940

    Preparation of a 3d model for skeleton example. The model is from Sophie Kahn and distributed by #additivism (their selection is really good!).

    Image of the model in the 3d additivism cookbook:

    rhino

    First step was to reduce (a lot) the number of faces of the model ( around 75% ), generate a UV map and link it to an armature, in blender, obviously. Note that the armature is displayed using Envelope. I never use it to work, but i find it lovely for screenshots.

    rhino-screenshot-002

    rhino-screenshot-001

    The skinning was tricky, due to the mesh mess. There are no arms for instance.

    After the export and conversion via OgreXMLconverter, the model has been easily imported in the engine.

    A lot of fine-tuning has been done on the material, to display solid and wireframe + having a light emission of the wireframe pass in the shadows.

    Here is the material definition:

    pass sophiekhan-mat
    {
    	ambient 0.8 0.8 0.8 1.0
    	diffuse 0.8 0.8 0.8 1.0
    	specular 0.02 0.05 0.05 1.0 0.1
    	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
    
    }
    pass sophiekhan-wf
    {
    	ambient 0.0 0.0 0.0 1.0
    	diffuse 0.85 0.7 0.75 1.0
    	specular 0.5 0.5 0.5 1.0 30.2
    	emissive 0.31 0.26 0.2 1.0
    	polygon_mode wireframe
    	transparent_sorting on
    }
    

    Other screenshots:

    screenshot01122017_171414743

    screenshot01122017_171208673

     
  • frankiezafe 22:47 on 2016-10-30 Permalink | Reply
    Tags: , material,   

    Chaise pagholz in blender, with @louise.

    chair-screenshot

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel