Skip to content

Instantly share code, notes, and snippets.

@jalava
Created July 21, 2011 04:37
Show Gist options
  • Select an option

  • Save jalava/1096493 to your computer and use it in GitHub Desktop.

Select an option

Save jalava/1096493 to your computer and use it in GitHub Desktop.

Revisions

  1. jalava created this gist Jul 21, 2011.
    41 changes: 41 additions & 0 deletions gistfile1.as
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    private var _vertCode:String =
    // move by speed´
    // calculate time delta vt0 = age = time-spawnTime;
    "sub vt0, vc"+time+".xxxx,va3.xxxx\n"+
    // life left -> vt1 = lifeLeft = life-age;
    "sub vt1, va3.yyyy, vt0.xxxx\n"+
    // 1-(lifeleft/life)
    "div vt1, vt1, va3\n"+
    "sub vt1, vc"+ONE+", vt1\n"+

    // Vertex Alpha = startalpha-((end alpha - start alpha)*lifeLeft)
    // vt2 = va3.w - va3.z
    "sub vt2,va3.wwww,va3.zzzz\n"+
    // vt2 = vt2/vt1
    "mul vt2,vt2.wwww,vt1.xxxx\n"+
    // vt2 = va3.z-v2
    "sub vt2, vt2.xxxx , va3.zzzz \n"+
    "min vt2, vc"+ONE+", vt2\n"+
    //"div vt4, "
    "mul vt0, va4, vt0.xxxx \n"+
    "add vt0, vt0.xyz, va0 \n"+
    // Expand corners
    /* "add vt0, vt2, vc[va2.x] \n" + */
    "add vt0, vt0, vc[va2.x] \n" +
    // Offset to place
    "m44 op, vt0, vc"+mat+"\n" +

    // Send color from stream 3
    // "mov v0, va3 \n" +
    // Texture UV
    "mov v1, va1 \n"+
    "mov vt2.xyz, vc"+ONE+".xyz \n"+
    "mov v2, vt2 \n"+
    "";

    // TODO: Particle fog
    private var _fragCode:String = "mov ft0, v1\n"+
    "tex ft1, ft0, fs0 <2d,linear,clamp>\n"+
    "mul ft1.w, ft1.w, v2.w \n"+
    // "mul ft1, ft1, v0 \n"+
    "mov oc, ft1\n";