0
votes

I am trying to port this GLSL Shaders to Stage3D and AGAL, but I cannot make it work:

Vertex Shader (GLSL)

attribute vec3 aVertexPosition;
    attribute vec4 aVertexColor;

    uniform mat4 uMVMatrix;
    uniform mat4 uPMatrix;

    varying vec4 vColor;

    void main(void) {
        gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
        vColor = aVertexColor;
    }

Fragment Shader (GLSL)

    precision mediump float;

    varying vec4 vColor;

    void main(void) {
        gl_FragColor = vColor;
    }

Having as a result:

Vertex Shader (AGAL)

mov vt0.w, vc0.x
mov vt0.xyz, va0.xyz

mov vt1.xyzw, vc1
mul vt5.xyzw, vt1, vc5
m44 op.xyzw, vt0.xyzw, vt5
mov v0.xyzw, va1.xyzw

Fragment Shader (AGAL)

mov oc.xyzw, v0.xyzw

Here it is a trace of the instructions I execute:

(setVertexBufferAt) va0 3 0
(setVertexBufferAt) va1 4 3
(identity setProgramConstantsFromMatrix): vc0 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1
(setProgramConstantsFromMatrix) vc1 1,0,0,0,0,1,0,0,0,0,1,0,0,0,-2,1
(setProgramConstantsFromMatrix) vc5 1.8106601238250732,0,0,0,0,2.4142136573791504,0,0,0,0,-1.0020020008087158,-1,0,0,-0.20020020008087158,0
render drawTriangles + present

But I can't still see anything.

Update: Apparently the problem is that the triangle is being clipped. Values on the multiplicated array are bigger than 1.0 which makes them clipped out. So I need to find a way to normalize the matrix or yo extend the clipping

Any suggestion?

1
Two thoughts: 1. What would happen if you removed the ".xyzw" from register access of the matrices? 2. There is no z component in va0. It looks like it only has an x and a y (based on your trace). Is this correct?bwroga
@bwroga I just found one of the possible causes.Mc-

1 Answers

0
votes

Digging up an old post here, but for the sake of any future searches you should really check out:

https://github.com/adobe/glsl2agal

It works pretty much as you would hope - takes valid glsl vertex/fragment shader programs as input, spits out valid agal as output.

as an example: http://www.cmodule.org/glsl2agal/