1

I want a pixel shader om AGAL that instead of simply copying the color passed to it from the vertex shader to the output, only copies the red component from the passed color and sets the green and blue components to zero. In pseudo code:

temp = 0
temp.red = in.red
temp.alpha = in.alpha
out = temp

I can't figure out how to write this in AGAL. The following doesn't do it:

mov ft0.ra, v0.ra
mov oc, ft0

How can I get the result I want?

1 Answers1

1

You must remember that

  • using ".something" on the right of the destination register means you are using masks
  • using ".something" on the right of a source register means you are using swizzles.

Supposing that

  • fc0 contains a zero in the first component
  • v0 contains the color from which you want to extract the red component

So here is your fragment shader:

// shader.
mov ft0, fc0.xxxx     // fill ft0 with zeros
mov ft0.xw, v0.xxxw   // fill ft0.x with v0.x and ft0.w with v0.w
mov oc, ft0

Source: I wrote Minko's ActionScript 3 to AGAL compiler.

Eloims
  • 5,106
  • 4
  • 25
  • 41