; constants
.constf const0(2.0, 1.0, 0.5, 0.25)
.constf const1(3.05185094e-005, 0.00392156886, 0.00784313725, 0.0)

; uniforms
.fvec uViewProj[4]
.fvec uBasis[32*2]

; in
.alias aCoord    v0
.alias aNormal   v1
.alias aTexCoord v2
.alias aColor    v3
.alias aLight    v4

; out
.out vPosition position
.out vTexCoord texcoord0
.out vColor    color

.proc main
; mulQuat
    mul r0.x, const0.xxxx, aCoord.wwww

    mova a0.x, r0.x
    mul r0.xyz, uBasis[a0.x], aCoord.zxyw
    mad r0.xyz, aCoord, uBasis[a0.x].zxyw, -r0
    mad r0.xyz, aCoord.yzxw, uBasis[a0.x].w, r0
    mul r1.xyz, uBasis[a0.x].zxyw, r0
    mad r0.xyz, r0.yzxw, uBasis[a0.x].yzxw, -r1
    mad r0.xyz, r0, const0.x, aCoord
    add r0.xyz, uBasis[a0.x + 1], r0
    mov r0.w, uBasis[a0.x + 1].w

; uViewProj * coord
    mul r1, uViewProj[0], r0.xxxx
    mad r1, r0.yyyy, uViewProj[1], r1
    mad r1, r0.zzzz, uViewProj[2], r1
    mad vPosition, r0.wwww, uViewProj[3], r1

    mul vTexCoord, const1.xxxx, aTexCoord.xyzw

    mul r3, const1.yyyy, aColor
    mul r4, const1.yyyy, aLight
    mul vColor, r3, r4

    end
.end
