Fur - vertex shader method

In vertex shader method, you load a shader file to material, then assign the material to mobile for fur effect. You needs check mobile's 'Bump' style for correct lighting. All shader files for VS fur method can be found at the "effects\fur\vs" folder.


Shader File
Preview Explanation
fur.sha One light lighting, one layer texture
fur_2lights.sha Two lights lighting, one layer texture
fur2t.sha One light lighting, two layers texture
fur2t__2lights.sha Two lights lighting, two layers texture


Factors
of all fur shaders:

number shelldistance            //distance between two shells
vec4 ambient                        //ambient color
vec4 diffuse                            //diffuse color
vec4 specular                        //specular color
vec4 uv                                //vector for uv transform;  x,y - uv scale; z,w - uv offset; u = u * x + z; v = v * y + w

Usage:

material.setEffectVector('vecShellDistance',vec4.new(
shelldistance,0,0,1))
material.setEffectVector('vecAmbient',
ambient)
material.setEffectVector('vecDiffuse',
diffuse)
material.setEffectVector('vecSpecular',
specular)
material.setEffectVector('vecUV',
uv)

Example:

(fur = material)

-- set material colors to fur shader
local amb=fur.getAmbient()*0.1
fur.setEffectVector('vecAmbient',vec4.new(amb.r,amb.g,amb.b,amb.a))
local dif=fur.getDiffuse()*0.1
fur.setEffectVector('vecDiffuse',vec4.new(dif.r,dif.g,dif.b,dif.a))
local spe=fur.getSpecular()*0.1
fur.setEffectVector('vecSpecular',vec4.new(spe.r,spe.g,spe.b,spe.a))

-- set fur length
local shelldistance=0.2
fur.setEffectVector('vecShellDistance',vec4.new(shelldistance,0,0,1))

-- set fur density & sway fur
local density=4
local sway=math.sin(GetFrameTime()*2)/200
fur.setEffectVector('vecUV',vec4.new(density,density,sway,sway))