Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with matrix in Flash #375

Closed
romamik opened this issue Aug 13, 2016 · 2 comments
Closed

Problem with matrix in Flash #375

romamik opened this issue Aug 13, 2016 · 2 comments

Comments

@romamik
Copy link

romamik commented Aug 13, 2016

Render code:

        var projection = FastMatrix4.orthogonalProjection( -framebuffer.width / 4, framebuffer.width / 4, framebuffer.height / 4, -framebuffer.height / 4, 0.1, 1000);
        var model = FastMatrix4.rotation(0, angle * Math.PI / 180, 0).multmat(FastMatrix4.translation( -50, -50, 0));
        var matrix = projection.multmat(model);

        var g4 = framebuffer.g4;
        g4.begin();
        g4.clear(Color.Black);

        g4.setVertexBuffer(vertexBuffer);
        g4.setIndexBuffer(indexBuffer);
        g4.setPipeline(shaderPipeline);
        g4.setTexture(textureLocation, Assets.images.bitmap);
        g4.setMatrix(projectionLocation, matrix);
        g4.setTextureParameters(textureLocation, TextureAddressing.Clamp, TextureAddressing.Clamp, TextureFilter.LinearFilter, TextureFilter.LinearFilter, MipMapFilter.NoMipFilter);
        g4.drawIndexedVertices(0, 6);
        g4.setTexture(textureLocation, null);
        g4.end();

And in flash for angles from 90 to 270 my picture dissappears. I also tested in windows and HTML5 and it's ok. I'm using shaders used by Graphics2.

Manually applying the same matrix and setting shader matrix to identity makes it work...

Example project: matrixWTF.zip

@romamik
Copy link
Author

romamik commented Aug 15, 2016

So I made more simple example and found that the problem is in the agal code.

matrixwtf2.zip

GLSL source:

#version 100

attribute vec3 vertexPosition;
uniform mat4 projectionMatrix;

void kore() {
    gl_Position = projectionMatrix * vec4(vertexPosition, 1.0);
}

Generated ".vert.agal" file:

{
    "varnames": {
        "gl_Position": "vt0",
        "projectionMatrix": "vc0",
        "vertexPosition": "va0"
    },
    "consts": {
        "vc0": [0.5],
        "vc1": [0.5],
        "vc2": [0.5],
        "vc3": [0.5],
        "vc4": [1.0, 1.0, 1.0, 1.0]
    },
    "agalasm": "mov vt0, vc0\nmov vt1, vc1\nmov vt2, vc2\nmov vt3, vc3\nmov vt4, va0\nmov vt5, vt4.xxxx\nmov vt6, vt4.yyyy\nmov vt4, vt4.zzzz\nmov vt5.x, vt5.x\nmov vt5.y, vt6.y\nmov vt5.z, vt4.z\nmov vt5.w, vc4.w\nm44 vt0, vt5, vt0\nmov vt0, vt0\nadd vt1.xxxx, vt0.zzzz, vt0.wwww\nmul vt0.z, vc0.x, vt1.x\nmov op, vt0\n",
} 

And when I change agal to

    "agalasm": "m44 op,va0,vc0\n"

Everything begin to work correctly.

@RobDangerous
Copy link
Member

This issue was moved to Kode/krafix#37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants