10 Ekim 2013 Perşembe

Vertex Color Shader in unity

Hi,
I have realized Unity3d does not have a shader for vertex colored models.

Since it is one of the easiest ways to color your model in Blender (Vertex Painting), you might need this shader:

Go to your assests folder - Create - Shader.
Give a name to your shader and paste the code below: (The name in code is "Vertex Colored", you can change it with your shader name).

Keep in mind, that you need create a material for your model if it is not created. Then you can choose this shader on material's shader list.

And make the ambient light white to see it properly. (Render Settings - Ambient Light)

Cheers


Vertex Color Shader Script

Source:
http://wiki.unity3d.com/index.php?title=VertexColor


Shader " Vertex Colored" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
    _Emission ("Emmisive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.7
    _MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader {
    Pass {
        Material {
            Shininess [_Shininess]
            Specular [_SpecColor]
            Emission [_Emission]    
        }
        ColorMaterial AmbientAndDiffuse
        Lighting On
        SeperateSpecular On
        SetTexture [_MainTex] {
            Combine texture * primary, texture * primary
        }
        SetTexture [_MainTex] {
            constantColor [_Color]
            Combine previous * constant DOUBLE, previous * constant
        } 
    }
}

Fallback " VertexLit", 1
}

8 Ekim 2013 Salı

Blogger - Add Code Highlight

If you like to highlight the codes you share in blogger, what you can do is:

Go to link
http://formatmysourcecode.blogspot.com/

Paste your code in there, press `format text` and get your html code.
Then, in your entry, go to `HTML` section and paste your code.

That's all,
SyntaxHighlighter and other highlighters were very frustrating for me..