diff --git a/assets/models/cube.obj b/assets/models/cube.obj new file mode 100644 index 0000000..905ecdb --- /dev/null +++ b/assets/models/cube.obj @@ -0,0 +1,21 @@ +v 0.5 -0.5 -0.5 +v 0.5 0.5 -0.5 +v -0.5 0.5 -0.5 +v -0.5 -0.5 -0.5 +v 0.5 -0.5 0.5 +v 0.5 0.5 0.5 +v -0.5 0.5 0.5 +v -0.5 -0.5 0.5 + +f 1 2 5 +f 2 6 5 +f 2 3 6 +f 3 7 6 +f 2 1 4 +f 2 4 3 +f 5 6 8 +f 6 7 8 +f 3 4 8 +f 3 8 7 +f 4 1 5 +f 4 5 8 diff --git a/assets/shaders/shader.frag b/assets/shaders/shader.frag new file mode 100644 index 0000000..6ea1f92 --- /dev/null +++ b/assets/shaders/shader.frag @@ -0,0 +1,15 @@ +varying vec3 fNormal; + +vec3 ambientLight = vec3(0.2,0.2,0.2); +vec3 directionnalLight = normalize(vec3(10,5,7)); +vec3 directionnalLightFactor = vec3(0.5,0.5,0.5); + + +void main() { + + vec3 ambientFactor = ambientLight; + vec3 lambertFactor = max(vec3(0.0,0.0,0.0), dot(directionnalLight, fNormal) * directionnalLightFactor); + + vec4 texel = texture2D(tex, gl_TexCoord[0].xy); + gl_FragColor = vec4(ambientFactor + lambertFactor, 1.0); +} diff --git a/assets/shaders/shader.vert b/assets/shaders/shader.vert new file mode 100644 index 0000000..86558ff --- /dev/null +++ b/assets/shaders/shader.vert @@ -0,0 +1,8 @@ +varying vec3 fNormal; +varying vec4 fTexCoord; + +void main() { + fNormal = gl_Normal; + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; +}