Overlapping Triangles Worksheet Answers
Click Here >> https://urluso.com/2tcLJ4
I'm trying to create a program without css that displays several overlapping triangles on a black background. Once I can get the triangles to display (like in the picture attached only with different colors), I need to implement either a z-buffer or a painter's algorithm; but first, I can't figure out what's wrong in the code below that they aren't displaying at all. I think it's an issue with my shaders perhaps?
uniform mat4 MVP; attribute vec3 vertexPosition; attribute vec3 normal; attribute vec2 texCoord; varying float vColor; varying vec3 vNormal; void main() { gl_Position = MVP * vec4(vertexPosition, 1.0); vColor = texture2D(u_texture, texCoord).a; vNormal = normalize(vec3(u_normal)); } And this fragment shader:
uniform vec4 u_fragColor; uniform vec3 u_color; varying float vColor; varying vec3 vNormal; void main() { float linearize = dot(vNormal, normalize(u_normal)); if (linearize < 0.0){ gl_FragColor = vec4(u_fragColor * vNormal, 1.0); } else { gl_FragColor = vec4(u_color, 1.0); } if (vColor > 0.0){ gl_FragColor.rgb *= vColor; } } By "worksheet answers" I mean the final image should look something like this: d2c66b5586