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

Inferring floats for shader output #9

Open
sgrove opened this issue May 14, 2015 · 0 comments
Open

Inferring floats for shader output #9

sgrove opened this issue May 14, 2015 · 0 comments

Comments

@sgrove
Copy link
Contributor

sgrove commented May 14, 2015

This shader:

(def program-source
  (p/program
   {:vertex-shader   {(g/gl-position) (-> u-p-matrix
                                          (g/* u-mv-matrix)
                                          (g/* (g/vec4 a-position 1)))
                      v-texture-coord a-texture-coord
                      v-light-weighting (g/if u-use-lighting
                                          (let [transformed-normal          (g/* u-n-matrix a-vertex-normal)
                                                directional-light-weighting (g/max (g/dot transformed-normal u-lighting-direction) 0.0)]
                                            (g/* directional-light-weighting
                                                 (g/+ u-ambient-color u-directional-color)))
                                          (g/vec3 1 1 1))}})}))

is output as:

uniform mat3 uNMatrix;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform vec3 uAmbientColor;
uniform vec3 uDirectionalColor;
uniform vec3 uLightingDirection;
attribute vec3 aVertexNormal;
attribute vec3 aVertexPosition;
attribute vec2 aTextureCoord;
uniform bool uUseLighting;
varying mediump vec2 vTextureCoord;
varying mediump vec3 vLightWeighting;
void main(void){
vec3 v90;
if(uUseLighting){
  (v90 = (max(dot((uNMatrix * aVertexNormal), uLightingDirection), 0) * (uAmbientColor + uDirectionalColor)));}
  else {
    (v90 = vec3(1, 1, 1));}
(gl_Position = ((uPMatrix * uMVMatrix) * vec4(aVertexPosition, 1)));
(vTextureCoord = aTextureCoord);
(vLightWeighting = v90);
}

And will fail because the 0.0 is output as 0, and according to this max requires a float. There also doesn't seem to be any casting functions to manually work around this for the time being.

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

1 participant