kovasb / gamma

glsl shaders made simple
Eclipse Public License 1.0
306 stars 20 forks source link

gamma.api/* doesn't work with mat4 #3

Closed sgrove closed 9 years ago

sgrove commented 9 years ago

In the spirit of every gl-lib, I'm porting http://learningwebgl.com/blog/?p=28 over to gamma. Ran into an issue with the first example vertex shader:

 attribute vec3 aVertexPosition;

  uniform mat4 uMVMatrix;
  uniform mat4 uPMatrix;

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

Which I believe the equivalent gamma is:

(def vertex-position
  (g/attribute "aVertexPosition" :vec3))

(def p-matrix
  (g/uniform "uPMatrix" :mat4))

(def mv-matrix
  (g/uniform "uMVMatrix" :mat4))

(def vertex-shader
  {(g/gl-position) (-> (g/* u-p-matrix u-mv-matrix)
                       (g/* (g/vec4 vertex-position 1)))})

But this results in: Uncaught Error: Arguments to * must have type :int or :float, given :mat4 and :vec4

kovasb commented 9 years ago

Looks like this got broken in a recent commit. Need to fix arithmetic-type, probably refactor all the operator inference logic. Definitely need more tests but its rather laborious given the surface area and number of layers...

sgrove commented 9 years ago

Just making sure, I'll comment out the arithmetic checks for the time being then.

kovasb commented 9 years ago

it also does inference, which is necessary for declaring locals (should they be needed)

kovasb commented 9 years ago

fixed as of https://github.com/kovasb/gamma/commit/163eed9aea67e5444e26f5a1fa328bbe584ec71f

kovasb commented 9 years ago

opening a new issue on the general topic https://github.com/kovasb/gamma/issues/4 until this is more thorough.