Recent Updates Toggle Comment Threads | Keyboard Shortcuts

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

    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, ,   

    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 15:29 on 2017-06-16 Permalink | Reply
    Tags: assets, , ,   

    Back to shadows problem, currently implementing a clean version of the Parallel-split shadow maps (pssm) in a way it could be packed nicely in the standard assets of the engine.

    , source: https://www.researchgate.net/publication/220805307_Parallel-split_shadow_maps_for_large-scale_virtual_environments

    End of the day

    PSSM shadows are applied “correctly” in the materials. Still a lot do to to be able to set the shadows from the xml…

     
  • frankiezafe 20:22 on 2017-06-14 Permalink | Reply
    Tags: , computational geometry, , ,   

    Straight skeleton C++ implementation 

    Long time no seen!

    Lot of things happens in may and june, that’s one of the reason of this long silence. The other is the library i’m working on to generate the maps of Disrupted Cities. Implementing a complex process in an efficient way is harsh. But it starts to works nicely.

    A small openframeworks demonstrates the part of the lib dedicated to shrink the 2D shapes, used later in the map to generate the block of houses.

    Shrink Demo on bitbucket.

    See you soon for more.

     
  • frankiezafe 19:45 on 2017-04-24 Permalink | Reply
    Tags: , , , ,   

    Long time no see, but polymorph engine development is back on track!

    The XML describing a polymorph’s project is now able to configure the Ogre’s compositor, understand the post-processing module.

    The first screenshot is using a custom compositor with this configuration:

    <workspace name="TuningScoreWS">
      <script group="General" workspace="CustomCompositor" />
      <colors>
        <color name="background_center" value="0,1,0" node="0" pass="1" index="4"/>
        <color name="background_border" value="1,0,0" node="0" pass="1" index="8"/>
      </colors>
      <variables>
        <variable name="centerx" value="0.5" node="0" pass="1" index="0"/>
        <variable name="centery" value="0.5" node="0" pass="1" index="1"/>
        <variable name="radius" value="0.9" node="0" pass="1" index="2"/>
        <variable name="ratio" value="1.777777778" node="0" pass="1" index="3"/>
      </variables>
    </workspace>
    

    The required files for this compositor (shaders & nodes) can be found in the samples example.compositor.

    The second screenshot is using a default compositor, where only the background color can be modified.

    <workspace name="Default">
      <colors>
        <color name="background" value="1,0,0"/>
      </colors>
    </workspace>
    

    The documentation about the XML is here: https://bitbucket.org/polymorphteam/pe.2.0/wiki/xml-specifications

     
  • frankiezafe 20:42 on 2017-04-17 Permalink | Reply
    Tags: , , , ,   

    To prepare the work session between Tomas Turine and Lisa Nelson, I prepared a OSC serialisation of all the objects available in the 3D world, including mouse and cameras, and built an interface in pd to visualise and use the data.

     
  • frankiezafe 11:57 on 2017-04-15 Permalink | Reply
    Tags: , , , ,   

    My website being back online, I will document the researches related to disrupted cities in several pages there.

    I’m currently working on an algorithm to nicely shrink the blocks detected in the network…

     
  • frankiezafe 14:31 on 2017-04-07 Permalink | Reply
    Tags: , , wiki,   

    Documentation about the XML format used to describe projects in the engine is available in the wiki. Please note that it might change in the upcoming month…

    Link in he wiki: https://bitbucket.org/polymorphteam/pe.2.0/wiki/xml-specifications

     
  • frankiezafe 19:18 on 2017-04-04 Permalink | Reply
    Tags: , ,   

    Today, certainly one of the less sexy thing i’ve ever posted…

    How to create a unique key out of two pointers in C++?

    After some investigation and a poor attempt to use boost uint128_t, i found my way using a char array.

    Here is the code:

    SomeClass* a = new SomeClass();
    SomeClass* b = new SomeClass();
    
    unique = new unsigned char[ 16 ]; // room for 64bits pointers
    uintptr_t ta = reinterpret_cast<uintptr_t>(a);
    uintptr_t tb = reinterpret_cast<uintptr_t>(b);
    
    for ( int i = 0; i < 8; ++i ) {
        unique[ i + 8 ] = ta;
        unique[ i ] = tb;
        ta = ta >> 8;
        tb = tb >> 8;
    }
    
    cout << "chars: ";
    for ( int i = 0; i < 16; ++i ) {
        cout << uint16_t( unique[i] ) << " | ";
    }
    cout << endl;
    
    uintptr_t newa = 
            unique[15] << 56 | 
            unique[14] << 48 | 
            unique[13] << 40 |
            unique[12] << 32 |
            unique[11] << 24 |
            unique[10] << 16 |
            unique[9] << 8 |
            unique[8];
    
    uintptr_t newb = 
            unique[7] << 56 | 
            unique[6] << 48 | 
            unique[5] << 40 |
            unique[4] << 32 |
            unique[3] << 24 |
            unique[2] << 16 |
            unique[1] << 8 |
            unique[0];
    
    cout << reinterpret_cast<uintptr_t>(a) << " <> " << newa << endl;
    cout << reinterpret_cast<uintptr_t>(b) << " <> " << newb << endl;
    cout << reinterpret_cast<RoadDot*>(newa) << " <> " << a << endl;
    cout << reinterpret_cast<RoadDot*>(newb) << " <> " << b << endl;
    

    And… done! The pointers are casted into the very useful uintptr_t as a unsigned int, stored in the array in 8 bits chunks. On 64 bits systems, pointers use 64bits… Therefore, the char array needs to have 16 slots ( 128 / 8 = 16 ).

    At the end of the code, the pointers are recreated from the characters and compared to the original values. In my terminal, here is what i saw:

    chars: 96 | 168 | 98 | 1 | 0 | 0 | 0 | 0 | 224 | 130 | 98 | 1 | 0 | 0 | 0 | 0 | 
    23233248 <> 23233248
    23242848 <> 23242848
    0x16282e0 <> 0x16282e0
    0x162a860 <> 0x162a860
    

    I’ll optimise this a bit, mainly by creating the char array based on the size of the uintptr_t * 2.

     
  • frankiezafe 16:33 on 2017-03-26 Permalink | Reply
    Tags: , code, ,   

    Finding the closest road on the right at a crossroad.

    To generate the bocks of building based on the roads structure, the method I’m building is based on a simple idea: when you arrives at a crossroad, you take the first street on the right and you go on like this until you reach a dead-end or your starting point. If you reach your starting point, the succession of roads you took defines a block of building. In theory. This technique has been suggested by Michel Cleempoel, on the way back from school.

    After a bit of preparation of the road network (removing orphan roads, having no connection with others, and dead-ends parts of the roads), the real problem arouse: how do you define right in a 3d environment, without an absolute ground reference. Indeed, I can configure the generator to use the Y axis (top axis in ogre3d) in addition to X & Z.

    At a crossroad, you may have several possibilities of roads. In the research, these possible roads are reduced to 3d vectors, all starting at world’s origin. The goal is to find the closest vector on the right of the current one, called the main 3d vector in the graphic above..

    The right is a complex idea, because it induces an idea of rotation. The closest on the right doesn’t mean the most perpendicular road on the right side. Let say I have 4 roads to choose from. Two going nearly in the opposite direction of the road i’m on, one perpendicular and one going straight on.

    If I compute the angles these roads have with the current one, results are:

    1. 5°,
    2. -5°,
    3. 90°,
    4. and 170°.

    The winner is not the 90°, but the 5° road! If I sort them, the last one must be the -5°, who is the first on the left.

    3d plane from a 3d vector

    The first thing to do is to define reference plane. To do so, you get the normal vector of the road by doing a cross product with the UP axis (Y axis in this case). The normal gives you a second vector, perpendicular to the road, and therefore defines a plane. Let’s call it VT plane, for Vector-Normal plane. For calculation, we need the vector perpendicular to this plane, rendered by crossing the road and its normal, let’s call it the tangent vector. Until here, it’s basic 3d geometry.

    projection of 3d vectors on a plane

    We can now project all the possible roads on the VT plane. These are the yellow vectors in the graphic. The math are clearly explained tmpearce on stackoverflow. Implemented in processing, it gives:

          float d = othervector.dot( tangent );
          PVector projectedvector = new PVector();
          projectedvector.add( tangent );
          projectedvector.mult( d * -1 );
          projectedvector.add( othervector );
    

    We are nearly done!

    angle between 3d vectors

    The projected vectors will help the angle calculation. Indeed, the current vector and the projected ones being coplanar, they share the same normal. The way to get the angle between 2 coplanar vectors is described by Dr. Martin von Gagern, on stackoverflow, once again. See Plane embedded in 3D paragraph for the code i’ve used.

    And… tadaaammmm! The number rendered by the method is the angle i was searching for, displayed in degrees in the graphic above.

     
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