现在的位置: 首页 > 综合 > 正文

AGAL指令说明

2013年06月18日 ⁄ 综合 ⁄ 共 1915字 ⁄ 字号 评论关闭

原文:http://www.saltgames.com/2011/stage-3d-shader-cheatsheet/

Operations
available to shaders:
  • mov t
    - Copy the contents of a into t.
  • add
    t a b
     - Add a and b,
    put result in t.
  • sub
    t a b
     – Subtract b from a,
    put result in t.
  • mul
    t a b
     – Multiple a and b,
    put result in t.
    When working component-wise this operation doesn’t always do as I’d expect. Specifically performing the operation:
    mul
    vt0.xy va0.xy vc0.xy

    Gives a different result from performing the two operations:
    mul
    vt0.x va0.x vc0.x
    mul vt0.y va0.y vc0.y

    Whereas they would give the same result if it were an add operation
    in both instances instead of mul.
    I’ve yet to work out exactly what the mul operation
    does with multiple components.
  • div
    t a b
     – Divide a by b,
    put result in t.
    The same behaviour as outlined above for the mul operation
    applies to div too.
  • rcp
    t a
     – Divide 1 by a,
    put result in t.
  • min
    t a b
     – Copy whichever of a or b is
    smaller into t.
  • max
    t a b
     – Copy whichever of a or b is
    larger into t.
  • frc
    t a
     – Copy just the fractional part of a into t.
    e.g. if a has
    the value 5.86 then 0.86 is placed in t.
  • sqt
    t a 
    - Find the square root of a,
    put result in t.
  • rsq
    t a
     – Find 1 divided by the square root of a,
    put result in t.
  • pow
    t a b
     – Raise a to
    the power of b,
    put result in t.
  • log
    t a
     – Find the binary
    logarithm
     of a,
    put result in t.
  • exp
    t a
     – Raise 2 to the power of a,
    put result in t.
  • nrm
    t a
     – Normalise the
    vector given in a (keep
    same direction, but make it length 1), put result in t.
  • sin
    t a
     – Find the sine of a,
    put result in t.
  • cos
    t a
     – Find the cosine of a,
    put result in t.
  • crs
    t a b
     – Find the cross
    product
     of the vectors a and b,
    put result in t.
  • dp3
    t a b
     – Find the dot
    product
     of the three-dimensional vectors a and b,
    put result in t.
  • dp4
    t a b
     – Find the dot
    product 
    of the four-dimensional vectors a and b,
    put result int.
  • abs
    t a
     – Find the absolute
    value
     of a, put result in t.
  • neg
    t a
     – Multiply a by -1, put result in t.
  • sat
    t a
     – Clamp a between
    1 and 0, put result in t.
    e.g. if a is
    -4.6, 0 will be placed in t.
    If a is
    0.6, 0.6 will be placed in t.
    If a is
    8.2, 1 will be placed in t.
  • m33
    t a b
     – Perform a 3×3 matrix multiply on a and b,
    put result in t.
  • m44
    t a b
     – Perform a 4×4 matrix multiply on a and b,
    put result in t.
  • m34
    t a b
     – Perform a 3×4 matrix multiply on 

抱歉!评论已关闭.