12 changed files with 1 additions and 344 deletions
|
Before Width: | Height: | Size: 559 KiB |
@ -1,11 +0,0 @@
|
||||
#version 330 core |
||||
|
||||
in vec3 frag_color; |
||||
|
||||
out vec4 color; |
||||
|
||||
|
||||
void main() |
||||
{ |
||||
color = vec4(frag_color, 1); |
||||
} |
||||
@ -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); |
||||
} |
||||
@ -1,11 +0,0 @@
|
||||
#version 330 core |
||||
|
||||
in vec3 frag_normal; |
||||
|
||||
out vec4 color; |
||||
|
||||
|
||||
void main() |
||||
{ |
||||
color = vec4(frag_normal, 1); |
||||
} |
||||
@ -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); |
||||
} |
||||
@ -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); |
||||
} |
||||
@ -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); |
||||
} |
||||
Binary file not shown.
@ -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" |
||||
} |
||||
] |
||||
} |
||||
@ -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); |
||||
} |
||||
@ -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); |
||||
} |
||||
Loading…
Reference in new issue