Tagged: material Toggle Comment Threads | Keyboard Shortcuts

  • frankiezafe 16:45 on 2018-01-03 Permalink | Reply
    Tags: , , material,   

    Normal map generation, using blender and processing.org.

    Read more here: Notes:Normal map generation.

     
  • frankiezafe 00:38 on 2017-10-19 Permalink | Reply
    Tags: , material, ,   

    Editing ogre materials:

     
  • frankiezafe 14:11 on 2017-10-11 Permalink | Reply
    Tags: , material, ,   

    Ogre3d really deserves some attention to deliver its full potential. A good example is the management of different version of shaders in a single program. In the image here above, the graphical cards are very different: the laptop has a low-end integrated intel chipset, the workstation is working with a GTX 980. The supported opengl version: glsl120 max for the laptop, vp40 for the gtx.

    This information is dumped in terminal when the application starts, search for something like this:

    Supported Shader Profiles: arbfp1 arbvp1 fp20 fp30 fp40 glsl glsl100 glsl110 glsl120 gp4fp gp4gp gp4vp gpu_fp gpu_gp gpu_vp nvgp4 vp30 vp40

    Once identified, we can now prepare a program script to select shaders automatically.

    In the .material:

    material shader_tester
    {
      technique{
        pass
        {
          fragment_program_ref tester_pix
          {
          }
        }
      }
    }

    In the .program:

    fragment_program tester_pix_glsl glsl
    {
      source tester_pix_120.glsl
    }

    fragment_program tester_pix_glsl_330 glsl
    {
      source tester_pix_330.glsl
      syntax fp40
    }

    fragment_program tester_pix unified
    {
      delegate tester_pix_glsl
      delegate tester_pix_glsl_330
    }

    The crucial instruction here is the syntax definition in fragment_program tester_pix_glsl_330. The available flags are listed here: Declaring Vertex/Geometry/Fragment Programs. The fragment_program tester_pix_glsl has no syntax flag, it will be used as the default one.

    Shaders are stupidly simple in this case.

    tester_pix_120.glsl

    void main() {
      gl_FragColor = vec4( 0,1,0,1 );
    }

    tester_pix_330.glsl

    #version 330
    void main() {
      gl_FragColor = vec4( 1,0,0,1 );
    }

    And that’s it for the automatic selection of shaders in ogre.

     
  • frankiezafe 19:40 on 2017-06-17 Permalink | Reply
    Tags: , material, ,   

    Working on a two passes material, the shadow pass being potentially added automatically in the material by enabling shadows.

    Here is how it looks:

    material two_pass_shadows
    {
      receive_shadows on

      technique
      {
        
        shadow_caster_material shadowscaster
        
        pass standard
        {
          ambient 0.0 0.0 0.0 1.0
          diffuse 0.8 0.8 0.8 1.0
          specular 0.0 0.0 0.0 1.0 0.0
          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
          
          // SUPER IMPORTANT TO AVOID FLICKERING
          depth_bias 0 -1
          
          texture_unit
          {
            texture rock.jpg
            tex_address_mode wrap
            scale 1 1
            colour_op modulate
          }
          
        }
        
        pass pssm
        {
          scene_blend add
          
          // SUPER IMPORTANT TO AVOID FLICKERING
          depth_bias 0 0
          
          vertex_program_ref ShadowsPssm_vert
          {
          }
          fragment_program_ref ShadowsPssm_pix
          {
          }
          texture_unit
          {
            content_type shadow
            tex_address_mode border
            tex_border_colour 1 1 1 1
          }
          texture_unit
          {
            content_type shadow
            tex_address_mode border
            tex_border_colour 1 1 1 1
          }
          texture_unit
          {
            content_type shadow
            tex_address_mode border
            tex_border_colour 1 1 1 1
          }
        }
        
      }
    }

    There is still issue with wireframe materials for instance ( polygon_mode wireframe ). Another issue is the poor definition of the shadows once the camera is a bit further.

    As shown in this image, there is a clear cut in definition when going from the near texture (green one, 2048) to the second one (red one, 1024). I guess I have to look much closer to the distance steps.

     
    • xuv 03:06 on 2017-06-19 Permalink | Reply

      Nice. We want moarrr screenshots :-D.
      Could you also make the last one work in realtime? Pleeez.

    • FdeCd 08:13 on 2017-06-19 Permalink | Reply

      cool!! And if you had blur that could be fix the definition problem… or not?
      Can’t wait to test it 😉

  • frankiezafe 19:26 on 2017-06-16 Permalink | Reply
    Tags: devporn, material,   

    Juste pour vos yeux, le dump d’un matériau Ogre:

     PMaterial:
        group: General
        name: shadows_pssm_cube
        receive shadows: 1
        transparency cast shadows: 0
        size: 3862
        techniques: 1
            technique[0]
                name:
                scheme: Default
                lod index: 0
        passes: 1
            pass[0]
                name: 0
            ** programs:
                vertex program: Shadows_pssm_vs
                fragment program: Shadows_pssm_ps
                compute program:
                shadow caster fragment program:
                shadow caster vertex program:
                tesselation domain program:
                tesselation hull program:
            ** colors:
                ambient: ColourValue( R:255, G:255, B:255, A:255 )
                diffuse: ColourValue( R:255, G:255, B:255, A:255 )
                emissive: ColourValue( R:0, G:0, B:0, A:255 )
                fog colour: ColourValue( R:255, G:255, B:255, A:255 )
                self illumination: ColourValue( R:0, G:0, B:0, A:255 )
                specular: ColourValue( R:0, G:0, B:0, A:255 )
            ** values:
                alpha reject value: 0
                depth bias constant: 0
                depth bias slope scale: 0
                fog density: 0.001
                fog end: 1
                fog start: 0
                hash: 0
                index: 0
                iteration depth bias: 0
                light count per iteration: 1
                light mask: -1
                max simultaneous lights: 8
                num shadow content textures: 3
                num texture unit states: 4
                pass iteration count: 1
                point attenuation constant: 1
                point attenuation linear: 0
                point attenuation quadratic: 0
                point max size: 0
                point min size: 0
                point size: 1
                shininess: 0
                start light: 0
            ** booleans:
                alpha coverage enabled: 0
                ambient light only: 0
                colour write enabled: 1
                depth check enabled: 1
                depth write enabled: 1
                fog override: 0
                iterate per light: 0
                light clip plane enabled: 0
                light scissoring enabled: 0
                lighting enabled: 1
                loaded: 1
                normalised normals: 0
                point attenuation enabled: 0
                point sprite enabled: 0
                polygon mode overrideable: 1
                programmable: 1
                run only for one light type: 0
                transparent: 0
                transparent sorting enabled: 1
                transparent sorting forced: 0
            ** enums:
                alpha reject function: CMPF_ALWAYS_PASS
                culling mode: CULL_CLOCKWISE
                depth function: CMPF_LESS_EQUAL
                dest blend factor: SBF_ZERO
                dest blend factor alpha: SBF_ZERO
                fog mode: FOG_NONE
                illumination stage: IS_UNKNOWN
                manual culling mode: MANUAL_CULL_BACK
                only light type: LT_POINT
                polygon mode: PM_SOLID
                scene blending operation: SBO_ADD
                scene blending operation alpha: SBO_ADD
                shading mode: SO_GOURAUD
                source blend factor: SBF_ONE
                source blend factor alpha: SBF_ONE
    TEXTURE UNIT COUNT = 4
    NUM TEXTURE UNIT STATES = 4
            textures: 4
                texture[0]
                    animation duration: 0
                    binding type: 0
                    colour blend fallback dest: 1
                    colour blend fallback src: 2
                    content type: 0
                    current frame: 0
                    desired format: 0
                    gamma: 1
                    alpha: 0
                    name: 0
                    num frames: 1
                    num mipmaps: -1
                    parent: 0x7f2a55d47a98
                    referenced MRT index: 18446463019639570529
                    texture anisotropy: 1
                    texture border colour: ColourValue(0, 0, 0, 1)
                    texture compare enabled: 0
                    texture compare function: 6
                    texture coord set: 0
                    texture mipmap bias: 0
                    texture name: cube.png
                    texture name alias: difftex
                    texture rotate: Radian(0)
                    texture transform: Matrix4( row0{1 0 0 0 } row1{0 1 0 0 } row2{0 0 1 0 } row3{0 0 0 1 })
                    texture type: 2
                    texture U scale: 1
                    texture U scroll: 0
                    texture V scale: 1
                    texture V scroll: 0
                texture[1]
                    animation duration: 0
                    binding type: 0
                    colour blend fallback dest: 1
                    colour blend fallback src: 2
                    content type: 1
                    current frame: 0
                    desired format: 0
                    gamma: 1
                    alpha: 0
                    name: 1
                    num frames: 0
                    num mipmaps: -1
                    parent: 0x7f2a55d47a98
                    referenced MRT index: 18446463019639570529
                    texture anisotropy: 1
                    texture border colour: ColourValue(1, 1, 1, 1)
                    texture compare enabled: 0
                    texture compare function: 6
                    texture coord set: 0
                    texture mipmap bias: 0
                    texture name:
                    texture name alias:
                    texture rotate: Radian(0)
                    texture transform: Matrix4( row0{1 0 0 0 } row1{0 1 0 0 } row2{0 0 1 0 } row3{0 0 0 1 })
                    texture type: 2
                    texture U scale: 1
                    texture U scroll: 0
                    texture V scale: 1
                    texture V scroll: 0
                texture[2]
                    animation duration: 0
                    binding type: 0
                    colour blend fallback dest: 1
                    colour blend fallback src: 2
                    content type: 1
                    current frame: 0
                    desired format: 0
                    gamma: 1
                    alpha: 0
                    name: 2
                    num frames: 0
                    num mipmaps: -1
                    parent: 0x7f2a55d47a98
                    referenced MRT index: 18446463019639570529
                    texture anisotropy: 1
                    texture border colour: ColourValue(1, 1, 1, 1)
                    texture compare enabled: 0
                    texture compare function: 6
                    texture coord set: 0
                    texture mipmap bias: 0
                    texture name:
                    texture name alias:
                    texture rotate: Radian(0)
                    texture transform: Matrix4( row0{1 0 0 0 } row1{0 1 0 0 } row2{0 0 1 0 } row3{0 0 0 1 })
                    texture type: 2
                    texture U scale: 1
                    texture U scroll: 0
                    texture V scale: 1
                    texture V scroll: 0
                texture[3]
                    animation duration: 0
                    binding type: 0
                    colour blend fallback dest: 1
                    colour blend fallback src: 2
                    content type: 1
                    current frame: 0
                    desired format: 0
                    gamma: 1
                    alpha: 0
                    name: 3
                    num frames: 0
                    num mipmaps: -1
                    parent: 0x7f2a55d47a98
                    referenced MRT index: 18446463019639570529
                    texture anisotropy: 1
                    texture border colour: ColourValue(1, 1, 1, 1)
                    texture compare enabled: 0
                    texture compare function: 6
                    texture coord set: 0
                    texture mipmap bias: 0
                    texture name:
                    texture name alias:
                    texture rotate: Radian(0)
                    texture transform: Matrix4( row0{1 0 0 0 } row1{0 1 0 0 } row2{0 0 1 0 } row3{0 0 0 1 })
                    texture type: 2
                    texture U scale: 1
                    texture U scroll: 0
                    texture V scale: 1
                    texture V scroll: 0

     
  • 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