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

Invalid fragment shader generated #168

Closed
pjcozzi opened this issue Nov 1, 2013 · 5 comments
Closed

Invalid fragment shader generated #168

pjcozzi opened this issue Nov 1, 2013 · 5 comments

Comments

@pjcozzi
Copy link
Member

pjcozzi commented Nov 1, 2013

A trivial model exported from Modo generates the following fragment shader, which does not compile because it doesn't define ambientLight.

@fabrobinet will send you the model.

precision highp float;
varying vec3 v_normal;
uniform vec3 u_light0Color;
uniform vec3 u_light1Color;
varying vec3 v_light1Direction;
uniform float u_shininess;
uniform vec4 u_diffuse;
uniform vec4 u_specular;
void main(void) {
vec3 normal = normalize(v_normal);
vec4 color = vec4(0., 0., 0., 0.);
vec4 diffuse = vec4(0., 0., 0., 1.);
vec3 diffuseLight = vec3(0., 0., 0.);
vec4 specular;
vec3 specularLight = vec3(0., 0., 0.);
{
float diffuseIntensity;
float specularIntensity;
ambientLight += u_light0Color;
}
{
float diffuseIntensity;
float specularIntensity;
vec3 l = normalize(v_light1Direction);
vec3 h = normalize(l+vec3(0.,0.,1.));
diffuseIntensity = max(dot(normal,l), 0.);
specularIntensity = pow(max(0.0,dot(normal,h)),u_shininess);
specularLight += u_light1Color * specularIntensity;
diffuseLight += u_light1Color * diffuseIntensity;
}
diffuse = u_diffuse;
specular = u_specular;
specular.xyz *= specularLight;
color.xyz += specular.xyz;
diffuse.xyz *= diffuseLight;
color.xyz += diffuse.xyz;
color = vec4(color.rgb * diffuse.a, diffuse.a);
gl_FragColor = color;
}
@pjcozzi
Copy link
Member Author

pjcozzi commented Nov 1, 2013

The conversion also outputs black for light0Color.

                "light0Color": {
                    "type": "FLOAT_VEC3",
                    "value": [
                        0,
                        0,
                        0
                    ]
                },

@fabrobinet
Copy link
Contributor

fixed on dev-2

Note: the model had issues, it refers to a camera but no cameras are defined.
By removing the reference to the camera in the dae file I could test the model.

@pjcozzi
Copy link
Member Author

pjcozzi commented Nov 2, 2013

Thanks - when are we merging dev-2 to master?

Also, will look into what the Modo exporter is doing; this should have been a trivial test case.

@fabrobinet
Copy link
Contributor

I hope by Wednesday.

@fabrobinet
Copy link
Contributor

now on master.

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

No branches or pull requests

2 participants