diff --git a/.gitignore b/.gitignore index dba8568..d1ac207 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/* bin/* tags Session.vim +data/ diff --git a/data/Color Palette 140.png b/data/Color Palette 140.png deleted file mode 100644 index 32f3bbb..0000000 Binary files a/data/Color Palette 140.png and /dev/null differ diff --git a/data/colored_vertices.frag b/data/colored_vertices.frag deleted file mode 100644 index 363c8ce..0000000 --- a/data/colored_vertices.frag +++ /dev/null @@ -1,11 +0,0 @@ -#version 330 core - -in vec3 frag_color; - -out vec4 color; - - -void main() -{ - color = vec4(frag_color, 1); -} diff --git a/data/colored_vertices.vert b/data/colored_vertices.vert deleted file mode 100644 index 464a63f..0000000 --- a/data/colored_vertices.vert +++ /dev/null @@ -1,22 +0,0 @@ -#version 330 core - -layout (location = 0) in vec3 position; -layout (location = 1) in vec3 color; - -out vec3 frag_color; - -layout (std140) uniform matrices -{ - mat4 view_xform; - mat4 proj_xform; - mat4 normal_xform; -}; - -uniform mat4 node_xform; - - -void main() -{ - frag_color = color; - gl_Position = proj_xform * view_xform * node_xform * vec4(position, 1); -} diff --git a/data/debug.frag b/data/debug.frag deleted file mode 100644 index 32af9c9..0000000 --- a/data/debug.frag +++ /dev/null @@ -1,11 +0,0 @@ -#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 deleted file mode 100644 index aa39fa4..0000000 --- a/data/debug.vert +++ /dev/null @@ -1,26 +0,0 @@ -#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/full_lighting.frag b/data/full_lighting.frag deleted file mode 100644 index f157004..0000000 --- a/data/full_lighting.frag +++ /dev/null @@ -1,67 +0,0 @@ -#version 330 core - -in vec3 frag_pos; -in vec3 frag_normal; -in vec2 frag_uv; - -out vec4 color; - -uniform sampler2D sampler; - -const uint NUM_LIGHTS = 32u; - -layout (std140) uniform lights -{ - uint max_p_lights; - uint active_p_lights; - uint max_d_lights; - uint active_d_lights; - uint padding; - - vec4 ambient_color; - - vec4 pl_positions[NUM_LIGHTS]; - vec4 pl_colors[NUM_LIGHTS]; - uint pl_intensities[NUM_LIGHTS]; // NOTE: 16 bytes * NUM_LIGHTS - - vec4 dl_directions[NUM_LIGHTS]; - vec4 dl_colors[NUM_LIGHTS]; - uint dl_intensities[NUM_LIGHTS]; // NOTE: 16 bytes * NUM_LIGHTS -}; - -const float CONSTANT_ATTENUATION = 0.1; -const float LINEAR_ATTENUATION = 0.2; -const float QUADRATIC_ATTENUATION = 0.02; - - -void main() -{ - vec4 diffuse_color = vec4(0); - - // NOTE: directional lights - for (uint i = 0u; i < active_d_lights; i++) { - vec4 light_direction = normalize(dl_directions[i]); - float diffuse_factor = - clamp(dot(vec4(frag_normal, 1), light_direction), 0, 1); - diffuse_color = diffuse_color + - dl_intensities[i] * diffuse_factor * dl_colors[i]; - } - - // NOTE: point lights - for (uint i = 0u; i < active_p_lights; i ++) { - vec3 direction = vec3(pl_positions[i]).xyz - frag_pos; - float distance = length(direction); - direction = direction / distance; - - float attenuation = CONSTANT_ATTENUATION + - LINEAR_ATTENUATION * distance + - QUADRATIC_ATTENUATION * pow(distance, 2); - float diffuse_factor = clamp(dot(frag_normal, direction), 0, 1); - vec4 added_color = pl_colors[i] * pl_intensities[i] - * diffuse_factor / attenuation; - - diffuse_color = diffuse_color + added_color; - } - - color = (ambient_color + diffuse_color) * texture(sampler, frag_uv.st); -} diff --git a/data/full_lighting.vert b/data/full_lighting.vert deleted file mode 100644 index f6fe8be..0000000 --- a/data/full_lighting.vert +++ /dev/null @@ -1,27 +0,0 @@ -#version 330 core - -layout (location = 0) in vec3 position; -layout (location = 1) in vec3 normal; -layout (location = 2) in vec2 uv; - -out vec3 frag_pos; -out vec3 frag_normal; -out vec2 frag_uv; - -layout (std140) uniform matrices -{ - mat4 view_xform; - mat4 proj_xform; - mat4 normal_xform; -}; - -uniform mat4 node_xform; - - -void main() -{ - frag_pos = (node_xform * vec4(position, 1)).xyz; - frag_uv = uv; - frag_normal = normalize(mat3(node_xform) * normal); - gl_Position = proj_xform * view_xform * node_xform * vec4(position, 1); -} diff --git a/data/icosphere.bin b/data/icosphere.bin deleted file mode 100644 index 9a8d721..0000000 Binary files a/data/icosphere.bin and /dev/null differ diff --git a/data/icosphere.gltf b/data/icosphere.gltf deleted file mode 100644 index 6e65847..0000000 --- a/data/icosphere.gltf +++ /dev/null @@ -1,137 +0,0 @@ -{ - "asset":{ - "generator":"Khronos glTF Blender I/O v4.4.56", - "version":"2.0" - }, - "scene":0, - "scenes":[ - { - "name":"Scene", - "nodes":[ - 0 - ] - } - ], - "nodes":[ - { - "mesh":0, - "name":"Icosphere" - } - ], - "materials":[ - { - "doubleSided":true, - "name":"Material.002", - "pbrMetallicRoughness":{ - "baseColorTexture":{ - "index":0 - }, - "metallicFactor":0, - "roughnessFactor":0.5 - } - } - ], - "meshes":[ - { - "name":"Icosphere.001", - "primitives":[ - { - "attributes":{ - "POSITION":0, - "NORMAL":1, - "TEXCOORD_0":2 - }, - "indices":3, - "material":0 - } - ] - } - ], - "textures":[ - { - "sampler":0, - "source":0 - } - ], - "images":[ - { - "mimeType":"image/png", - "name":"Color Palette 140", - "uri":"Color%20Palette%20140.png" - } - ], - "accessors":[ - { - "bufferView":0, - "componentType":5126, - "count":960, - "max":[ - 1, - 1, - 0.9999999403953552 - ], - "min":[ - -0.9999999403953552, - -1, - -0.9999999403953552 - ], - "type":"VEC3" - }, - { - "bufferView":1, - "componentType":5126, - "count":960, - "type":"VEC3" - }, - { - "bufferView":2, - "componentType":5126, - "count":960, - "type":"VEC2" - }, - { - "bufferView":3, - "componentType":5123, - "count":960, - "type":"SCALAR" - } - ], - "bufferViews":[ - { - "buffer":0, - "byteLength":11520, - "byteOffset":0, - "target":34962 - }, - { - "buffer":0, - "byteLength":11520, - "byteOffset":11520, - "target":34962 - }, - { - "buffer":0, - "byteLength":7680, - "byteOffset":23040, - "target":34962 - }, - { - "buffer":0, - "byteLength":1920, - "byteOffset":30720, - "target":34963 - } - ], - "samplers":[ - { - "magFilter":9729, - "minFilter":9987 - } - ], - "buffers":[ - { - "byteLength":32640, - "uri":"icosphere.bin" - } - ] -} diff --git a/data/texture_only.frag b/data/texture_only.frag deleted file mode 100644 index 311fa02..0000000 --- a/data/texture_only.frag +++ /dev/null @@ -1,21 +0,0 @@ -#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/texture_only.vert b/data/texture_only.vert deleted file mode 100644 index b5c343f..0000000 --- a/data/texture_only.vert +++ /dev/null @@ -1,22 +0,0 @@ -#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); -}