diff --git a/.gitattributes b/.gitattributes index 690fa1a..b2c62f6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,5 +2,3 @@ data/ filter=lfs diff=lfs merge=lfs -text data/textured_cube.bin filter=lfs diff=lfs merge=lfs -text data/textured_cube.gltf filter=lfs diff=lfs merge=lfs -text data/Color[[:space:]]Palette[[:space:]]140.png filter=lfs diff=lfs merge=lfs -text -*.frag filter=lfs diff=lfs merge=lfs -text -*.vert filter=lfs diff=lfs merge=lfs -text diff --git a/data/colored_vertices.frag b/data/colored_vertices.frag index ee32172..98d33f3 100644 --- a/data/colored_vertices.frag +++ b/data/colored_vertices.frag @@ -1,3 +1,33 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:72f1e8907ed599864745ca9dea086d4f401c11c224012fd140b33b145cd10cb3 -size 395 +#version 330 core + +in vec3 frag_vertex; +in vec3 frag_normal; +in vec3 frag_uv; +in vec3 frag_color; + +out vec4 color; + +layout (std140) uniform matrices +{ + mat4 view_xform; + mat4 proj_xform; + mat4 normal_xform; +}; + +struct light +{ + vec4 positions; + vec4 colors; +}; + +layout (std140) uniform lights +{ + light light_array[256]; +}; + +uniform mat4 node_xform; + +void main() +{ + color = vec4(frag_color, 1); +} diff --git a/data/colored_vertices.vert b/data/colored_vertices.vert index 529e7a2..c59c42a 100644 --- a/data/colored_vertices.vert +++ b/data/colored_vertices.vert @@ -1,3 +1,30 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:444205ec750a1587f095e598a57a86d2b8b1987709d42b50154493591d7d23c1 -size 548 +#version 330 core + +layout (location = 0) in vec3 position; +layout (location = 1) in vec3 normal; +layout (location = 2) in vec3 uv; +layout (location = 3) in vec3 color; + +out vec3 frag_vertex; +out vec3 frag_normal; +out vec3 frag_uv; +out vec3 frag_color; + +layout (std140) uniform matrices +{ + mat4 view_xform; + mat4 proj_xform; + mat4 normal_xform; +}; + +uniform mat4 node_xform; + + +void main() +{ + frag_vertex = position; + frag_normal = normal; + frag_uv = uv; + frag_color = color; + gl_Position = proj_xform * view_xform * node_xform * vec4(position, 1); +} diff --git a/data/debug.frag b/data/debug.frag index 9434495..32af9c9 100644 --- a/data/debug.frag +++ b/data/debug.frag @@ -1,3 +1,11 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:99c8ad1e2e1a229ff1a5154900b08c5bd89e19d42c34996a5fdcd3ac7161f225 -size 106 +#version 330 core + +in vec3 frag_normal; + +out vec4 color; + + +void main() +{ + color = vec4(frag_normal, 1); +} diff --git a/data/debug.vert b/data/debug.vert index 9942030..aa39fa4 100644 --- a/data/debug.vert +++ b/data/debug.vert @@ -1,3 +1,26 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:18f1000a8561121aca0cad6daad5f9c3084d54152c5732367caa27f71856e504 -size 560 +#version 330 core + +layout (location = 0) in vec3 position; +layout (location = 1) in vec3 normal; + +out vec3 frag_normal; + +layout (std140) uniform matrices +{ + mat4 view_xform; + mat4 proj_xform; + mat4 normal_xform; +}; + +uniform mat4 node_xform; + + +void main() +{ + // TODO: probably better to do this once in a separate uniform than once + // for every vertex + mat4 xform = node_xform; + xform[3] = vec4(0, 0, 0, 1); // NOTE: undo translation + frag_normal = vec4(xform * vec4(normal, 1)).xyz; + gl_Position = proj_xform * view_xform * node_xform * vec4(position, 1); +} diff --git a/data/shader.frag b/data/shader.frag index b5b26f3..f1c37f3 100644 --- a/data/shader.frag +++ b/data/shader.frag @@ -1,3 +1,20 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7ce3046e2f64aaa1b4b81726964d958fb5a28d13aba3895bf1b61a4deeaf3575 -size 257 +#version 330 core + +in vec2 frag_uv; + +out vec4 color; + +layout (std140) uniform matrices +{ + mat4 view_xform; + mat4 proj_xform; + mat4 normal_xform; +}; + +uniform mat4 node_xform; +uniform sampler2D sampler; + +void main() +{ + color = texture(sampler, frag_uv.st); +} diff --git a/data/shader.vert b/data/shader.vert index c8c2904..b5c343f 100644 --- a/data/shader.vert +++ b/data/shader.vert @@ -1,3 +1,22 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4204ea2e68fcfc90eb5f2fdfb713f3ea1f03028a970729199a2e08216afb100c -size 339 +#version 330 core + +layout (location = 0) in vec3 position; +layout (location = 1) in vec2 uv; + +out vec2 frag_uv; + +layout (std140) uniform matrices +{ + mat4 view_xform; + mat4 proj_xform; + mat4 normal_xform; +}; + +uniform mat4 node_xform; + + +void main() +{ + frag_uv = uv; + gl_Position = proj_xform * view_xform * node_xform * vec4(position, 1); +}