Dealing With AGAL Registers

Todo : 한국어로 의미를 써 보세요.

This is a thorough(완전한) tutorial on the use of registers for AGAL shaders.

예) - (nassol) 이 글은 AGAL shader에 대해 register를 사용하는 방법에 대한 완전한 튜토리얼입니다.

It is about

how to go about setting their values and accessing them in the shader.

This tutorial is more focused on theory

rather than the practical writing of code.

If you want to see how this gets applied,

please refer to my simple rendering example.

Registers:

Each register consists of four components.

Four components are floating point values.

A particular component is accessed by the notation [registerName].[componentLetter].

And here componentLetter is x, y, z, or w.

For example va0.x is the first component of the first vertex attribute register.

For a listing of the available registers, please see my AGAL reference page.

Vertex Buffer:

(패스하세요~ 이해되면 하시고요~)

The vertex buffer is how you pass per-vertex data into your vertex shader, where it will appear in the va (vertex attribute) registers.

Usually this will include

the position of that vertex in the world.

And this will include some data

which is used to colour it

(패스하세욤~ 이해되면 하시고요~)

– either by passing in a colour for the vertex, uv coordinates for texture mapping, or something more complex.

Keep in mind that the vertex buffer is just a series of floating point numbers.

And you can use the vertex buffer for anything you like in your shader.

To deal with the vertex buffer

you first create a VertexBuffer3D object

by using the function context3D.createVertexBuffer 

(you cannot just instantiate it yourself with new VertexBuffer3D().)  

This object will store the values

until you’re ready to upload them into registers

and until you have a shader use them.

Imagine the VertexBuffer3D object as a table.

When you create it

with context3D.createVertexBuffer

you specify

the number of vertices (the number of rows in the table)

and the number of data32 per vertex (the number of columns in the table).

In this illustration (이 그림에서)

I’ve labelled each column  (각 열에 이름을 붙였어요.)

with what I plan to use the values for,

but remember (기억하세요)

they’re only series of meaningless(무의미한) numbers

as far as Flash is concerned.