AGAL指令说明

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

Operations available to shaders:
  • mov t a - 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 a and b, put result in t.
  • m43 t a b – Perform a 4×3 matrix multiply on a and b, put result in t.
    I need to write a decent explanation of what matrix operations do.
    In all of these, b is the first register that makes up a matrix. For instance if you perform m44 with b as vc0 then the contents of registers vc0 vc1 vc2 vc3 will be used. a is a single register that gets multiplied through by the matrix specified in b.
  • sge t a b - If a is greater or equal to b put 1 in t, otherwise put 0 in t.
  • slt t a b – If a is less than b put 1 in t, otherwise put 0 in t.
    sge and slt are the closest we have to conditional flow control in AGAL so look out for ways to use multiplication of their 1 or 0 result in place of traditional conditionals.
Operations only available to fragment shaders:
  • kil a - a must be a single scalar value rather than a vector, for instance: ft0.x. If the value given is less than zero then execution on this fragment is halted and it is not drawn.
  • tex t a b <type, wrap, filter> - Samples the texture in b (which should be one of thefs registers) at the coordinates in a, putting the resulting colour in t.
    • type determines what kind of texture you’re sampling from, and should be either: “2d” for standard texturing or “cube” for using a cubemap.
    • wrap determines how to deal with sampling beyond the bounds of the texture, either: “clamp” or “repeat”.
    • filter determines how to interpolate between texels, either “mipnearest”, “miplinear” (both of those require mipmaps to have been uploaded for the texture), “nearest”, or “linear”. Use nearest if you want your texture to have crisp pixel edges, use linear if you want them smoothed out.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值