Home General Discussion

M3chDroid: Blender project

Hi there everyone!

I love to read this forum. I learn a lot from here. My favorite treath is this one (about low poly characters):

http://boards.polycount.net/showflat.php?Cat=0&Number=96988&an=0&page=0#Post96988

Iam a member of the Blender community, i don't know if this is the right place to post but... lets go!

http://www.dev.com.br/dimy/

It is a VERY VERY VERY simple demo made in Blender, it doesn't have all of this incredible features from new engines.

But... we made this with care and our intention was to help people starting with 3D modeling and you can download Blender from the internet for free. (Ok, ok... you can also download paid softwares for free in the internet, but that is another history wink.gif).

I hope you enjoy it. Critics and comments from this community are welcome!

Thank you very much,

Ortiz.

PS: sorry about my English, you could also contribute improving this. smile.gif

Replies

  • Richard Kain
    Offline / Send Message
    Richard Kain polycounter lvl 18
    Hmmm...I like the mech model you've created for this project. It is very simple, but the style is appealing. I also think you've done a good job with the shader/material applied to the mech. A variation on the toon shader, and it seems to work well.
  • mechdroid
    Wow! Thankx for your speed light feedback Kain!

    Actually when i started this projet Blender community did not have a GLSL python script with outline. So i worked with the most common two texture script we have, and with very simple texture styles to achieve this "cartoon look":

    import GameLogic as g
    objlist = g.getCurrentScene().getObjectList()
    g.setLogicTicRate(60.0)
    #
    ShaderObjects = [ objlist ]
    MaterialIndexList = [0,1]
    GlobalAmbient = [0.39,0.35,0.32,1]
    AmbF = 0.5
    #

    VertexShader = """
    uniform mat4 mvi;
    vec4 Tangent;

    varying vec4 vcol;

    varying vec3 lvec,vvec;

    vec3 TBN(in vec3 by)
    {
    vec3 tangent = (Tangent.xyz);
    vec3 binormal = cross(gl_Normal, Tangent.xyz)*Tangent.w;
    vec3 normal = gl_Normal;

    vec3 tvec;
    tvec.x = dot(tangent, by);
    tvec.y = dot(binormal, by);
    tvec.z = dot(normal, by);
    return tvec;
    }

    void main() {
    gl_Position = ftransform();

    // texcoord now (vec4())
    Tangent = gl_MultiTexCoord1;

    vec4 light0 = (mvi*gl_LightSource[0].position)-gl_Vertex;

    vec4 view = mvi[3]-gl_Vertex;

    lvec = TBN(light0.xyz);
    vvec = TBN(view.xyz);

    gl_TexCoord[0] = gl_MultiTexCoord0;

    vcol =gl_Color;
    }
    """

    FragmentShader = """
    varying vec4 vcol;
    varying vec3 lvec,vvec,hvec;


    uniform sampler2D color;
    uniform sampler2D bump;

    void main() {
    vec4 diffuse_color = vcol*gl_LightSource[0].diffuse;
    vec4 specular_color = gl_FrontMaterial.specular;
    vec4 colormap = texture2D(color, gl_TexCoord[0].st);

    vec3 lv = normalize(lvec);
    vec3 vv = normalize(vvec);
    vec3 nv = normalize(2.0*texture2D(bump, gl_TexCoord[0].st).xyz-1.0);

    float diff = max(dot(lv, nv), 0.0);
    float spec = pow(max(dot(reflect(-vv, nv), lv),0.0), gl_FrontMaterial.shininess);

    vec4 diff_pass = colormap*(diff*diffuse_color);
    vec4 spec_pass = spec*specular_color;
    gl_FragColor = vec4(0.1,0.1,0.1,1.0)+diff_pass+spec_pass;
    }
    """


    def MainLoop ():
    # for each object
    for obj in ShaderObjects:

    mesh_index = 0
    mesh = obj.getMesh(mesh_index)

    while mesh != None:

    for mat in mesh.materials:

    # regular TexFace materials do NOT have this function
    if not hasattr(mat, "getMaterialIndex"):
    return

    mat_index = mat.getMaterialIndex()

    # find an index
    found = 0
    for i in range(len(MaterialIndexList)):
    if mat_index == MaterialIndexList:
    found=1
    break
    if not found: continue

    shader = mat.getShader()
    if shader != None:
    if not shader.isValid():
    shader.setSource(VertexShader, FragmentShader,1)


    # shader.setAttrib(g.SHD_TANGENT)
    shader.setUniformDef('mvi', g.MODELVIEWMATRIX_INVERSE)
    shader.setSampler('color', 0)
    shader.setSampler('bump', 1)

    mesh_index += 1
    mesh = obj.getMesh(mesh_index)

    #

    MainLoop()
    #

    Nowadays, Piraniac have created a very cool script able to fake black outlines (i will try to integrate this into my project):

    http://blenderartists.org/forum/showthread.php?t=97601
Sign In or Register to comment.