basilisk-engine 0.1.35__py3-none-any.whl → 0.1.37__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of basilisk-engine might be problematic. Click here for more details.
- basilisk/__init__.py +26 -26
- basilisk/audio/sound.py +27 -27
- basilisk/bsk_assets/cube.obj +48 -48
- basilisk/collisions/broad/broad_aabb.py +102 -102
- basilisk/collisions/broad/broad_bvh.py +137 -137
- basilisk/collisions/collider.py +95 -95
- basilisk/collisions/collider_handler.py +225 -225
- basilisk/collisions/narrow/contact_manifold.py +95 -95
- basilisk/collisions/narrow/dataclasses.py +34 -34
- basilisk/collisions/narrow/deprecated.py +46 -46
- basilisk/collisions/narrow/epa.py +91 -91
- basilisk/collisions/narrow/gjk.py +66 -66
- basilisk/collisions/narrow/graham_scan.py +24 -24
- basilisk/collisions/narrow/helper.py +29 -29
- basilisk/collisions/narrow/line_intersections.py +106 -106
- basilisk/collisions/narrow/sutherland_hodgman.py +75 -75
- basilisk/config.py +54 -4
- basilisk/draw/draw.py +100 -100
- basilisk/draw/draw_handler.py +178 -175
- basilisk/draw/font_renderer.py +28 -28
- basilisk/engine.py +165 -165
- basilisk/generic/abstract_bvh.py +15 -15
- basilisk/generic/abstract_custom.py +133 -133
- basilisk/generic/collisions.py +70 -70
- basilisk/generic/input_validation.py +82 -74
- basilisk/generic/math.py +6 -6
- basilisk/generic/matrices.py +35 -35
- basilisk/generic/meshes.py +72 -72
- basilisk/generic/quat.py +142 -142
- basilisk/generic/quat_methods.py +7 -7
- basilisk/generic/raycast_result.py +26 -26
- basilisk/generic/vec3.py +143 -143
- basilisk/input_output/IO_handler.py +91 -91
- basilisk/input_output/clock.py +49 -49
- basilisk/input_output/keys.py +43 -43
- basilisk/input_output/mouse.py +90 -89
- basilisk/input_output/path.py +14 -14
- basilisk/mesh/cube.py +33 -33
- basilisk/mesh/mesh.py +233 -233
- basilisk/mesh/mesh_from_data.py +150 -150
- basilisk/mesh/model.py +271 -271
- basilisk/mesh/narrow_aabb.py +89 -89
- basilisk/mesh/narrow_bvh.py +91 -91
- basilisk/mesh/narrow_primative.py +23 -23
- basilisk/nodes/helper.py +28 -28
- basilisk/nodes/node.py +704 -695
- basilisk/nodes/node_handler.py +97 -97
- basilisk/particles/particle_handler.py +64 -64
- basilisk/particles/particle_renderer.py +93 -92
- basilisk/physics/impulse.py +112 -112
- basilisk/physics/physics_body.py +43 -43
- basilisk/physics/physics_engine.py +35 -35
- basilisk/render/batch.py +103 -103
- basilisk/render/bloom.py +108 -0
- basilisk/render/camera.py +260 -260
- basilisk/render/chunk.py +108 -106
- basilisk/render/chunk_handler.py +167 -165
- basilisk/render/frame.py +109 -95
- basilisk/render/framebuffer.py +203 -192
- basilisk/render/image.py +120 -120
- basilisk/render/image_handler.py +120 -120
- basilisk/render/light.py +96 -96
- basilisk/render/light_handler.py +58 -58
- basilisk/render/material.py +232 -221
- basilisk/render/material_handler.py +133 -133
- basilisk/render/post_process.py +139 -139
- basilisk/render/shader.py +134 -134
- basilisk/render/shader_handler.py +85 -83
- basilisk/render/sky.py +120 -120
- basilisk/scene.py +291 -290
- basilisk/shaders/batch.frag +289 -276
- basilisk/shaders/batch.vert +117 -115
- basilisk/shaders/bloom_downsample.frag +43 -0
- basilisk/shaders/bloom_frame.frag +25 -0
- basilisk/shaders/bloom_upsample.frag +34 -0
- basilisk/shaders/crt.frag +31 -31
- basilisk/shaders/draw.frag +25 -22
- basilisk/shaders/draw.vert +25 -25
- basilisk/shaders/filter.frag +22 -22
- basilisk/shaders/frame.frag +12 -12
- basilisk/shaders/frame.vert +13 -13
- basilisk/shaders/geometry.frag +10 -8
- basilisk/shaders/geometry.vert +41 -41
- basilisk/shaders/normal.frag +62 -59
- basilisk/shaders/normal.vert +96 -96
- basilisk/shaders/particle.frag +76 -71
- basilisk/shaders/particle.vert +86 -84
- basilisk/shaders/sky.frag +23 -9
- basilisk/shaders/sky.vert +13 -13
- basilisk_engine-0.1.37.dist-info/METADATA +89 -0
- basilisk_engine-0.1.37.dist-info/RECORD +110 -0
- {basilisk_engine-0.1.35.dist-info → basilisk_engine-0.1.37.dist-info}/WHEEL +1 -1
- basilisk/input/__init__.py +0 -0
- basilisk/input/mouse.py +0 -62
- basilisk/input/path.py +0 -14
- basilisk_engine-0.1.35.dist-info/METADATA +0 -45
- basilisk_engine-0.1.35.dist-info/RECORD +0 -109
- {basilisk_engine-0.1.35.dist-info → basilisk_engine-0.1.37.dist-info}/top_level.txt +0 -0
basilisk/shaders/geometry.vert
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
#version 330 core
|
|
2
|
-
|
|
3
|
-
layout (location = 0) in vec3 in_position;
|
|
4
|
-
|
|
5
|
-
layout (location = 5) in vec3 obj_position;
|
|
6
|
-
layout (location = 6) in vec4 obj_rotation;
|
|
7
|
-
layout (location = 7) in vec3 obj_scale;
|
|
8
|
-
|
|
9
|
-
// Uniforms
|
|
10
|
-
uniform mat4 projectionMatrix;
|
|
11
|
-
uniform mat4 viewMatrix;
|
|
12
|
-
|
|
13
|
-
// Function to get the model matrix from node position, rotation, and scale
|
|
14
|
-
mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
|
|
15
|
-
mat4 translation = mat4(
|
|
16
|
-
1 , 0 , 0 , 0,
|
|
17
|
-
0 , 1 , 0 , 0,
|
|
18
|
-
0 , 0 , 1 , 0,
|
|
19
|
-
pos.x, pos.y, pos.z, 1
|
|
20
|
-
);
|
|
21
|
-
mat4 rotation = mat4(
|
|
22
|
-
1 - 2 * (rot.z * rot.z + rot.w * rot.w), 2 * (rot.y * rot.z - rot.w * rot.x), 2 * (rot.y * rot.w + rot.z * rot.x), 0,
|
|
23
|
-
2 * (rot.y * rot.z + rot.w * rot.x), 1 - 2 * (rot.y * rot.y + rot.w * rot.w), 2 * (rot.z * rot.w - rot.y * rot.x), 0,
|
|
24
|
-
2 * (rot.y * rot.w - rot.z * rot.x), 2 * (rot.z * rot.w + rot.y * rot.x), 1 - 2 * (rot.y * rot.y + rot.z * rot.z), 0,
|
|
25
|
-
0, 0, 0, 1
|
|
26
|
-
);
|
|
27
|
-
mat4 scale = mat4(
|
|
28
|
-
scl.x, 0 , 0 , 0,
|
|
29
|
-
0 , scl.y, 0 , 0,
|
|
30
|
-
0 , 0 , scl.z, 0,
|
|
31
|
-
0 , 0 , 0 , 1
|
|
32
|
-
);
|
|
33
|
-
return translation * rotation * scale;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
void main() {
|
|
38
|
-
// Set the model matrix
|
|
39
|
-
mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
|
|
40
|
-
// Set the fragment position
|
|
41
|
-
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) in vec3 in_position;
|
|
4
|
+
|
|
5
|
+
layout (location = 5) in vec3 obj_position;
|
|
6
|
+
layout (location = 6) in vec4 obj_rotation;
|
|
7
|
+
layout (location = 7) in vec3 obj_scale;
|
|
8
|
+
|
|
9
|
+
// Uniforms
|
|
10
|
+
uniform mat4 projectionMatrix;
|
|
11
|
+
uniform mat4 viewMatrix;
|
|
12
|
+
|
|
13
|
+
// Function to get the model matrix from node position, rotation, and scale
|
|
14
|
+
mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
|
|
15
|
+
mat4 translation = mat4(
|
|
16
|
+
1 , 0 , 0 , 0,
|
|
17
|
+
0 , 1 , 0 , 0,
|
|
18
|
+
0 , 0 , 1 , 0,
|
|
19
|
+
pos.x, pos.y, pos.z, 1
|
|
20
|
+
);
|
|
21
|
+
mat4 rotation = mat4(
|
|
22
|
+
1 - 2 * (rot.z * rot.z + rot.w * rot.w), 2 * (rot.y * rot.z - rot.w * rot.x), 2 * (rot.y * rot.w + rot.z * rot.x), 0,
|
|
23
|
+
2 * (rot.y * rot.z + rot.w * rot.x), 1 - 2 * (rot.y * rot.y + rot.w * rot.w), 2 * (rot.z * rot.w - rot.y * rot.x), 0,
|
|
24
|
+
2 * (rot.y * rot.w - rot.z * rot.x), 2 * (rot.z * rot.w + rot.y * rot.x), 1 - 2 * (rot.y * rot.y + rot.z * rot.z), 0,
|
|
25
|
+
0, 0, 0, 1
|
|
26
|
+
);
|
|
27
|
+
mat4 scale = mat4(
|
|
28
|
+
scl.x, 0 , 0 , 0,
|
|
29
|
+
0 , scl.y, 0 , 0,
|
|
30
|
+
0 , 0 , scl.z, 0,
|
|
31
|
+
0 , 0 , 0 , 1
|
|
32
|
+
);
|
|
33
|
+
return translation * rotation * scale;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
void main() {
|
|
38
|
+
// Set the model matrix
|
|
39
|
+
mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
|
|
40
|
+
// Set the fragment position
|
|
41
|
+
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
|
|
42
42
|
}
|
basilisk/shaders/normal.frag
CHANGED
|
@@ -1,60 +1,63 @@
|
|
|
1
|
-
#version 330 core
|
|
2
|
-
|
|
3
|
-
layout (location = 0) out vec4 fragColor;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
float
|
|
14
|
-
float
|
|
15
|
-
float
|
|
16
|
-
float
|
|
17
|
-
float
|
|
18
|
-
float
|
|
19
|
-
float
|
|
20
|
-
float
|
|
21
|
-
float
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
in
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if
|
|
47
|
-
|
|
48
|
-
normal =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) out vec4 fragColor;
|
|
4
|
+
layout (location = 1) out vec4 bloomColor;
|
|
5
|
+
|
|
6
|
+
// Structs needed for the shader
|
|
7
|
+
struct textArray {
|
|
8
|
+
sampler2DArray array;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
struct Material {
|
|
12
|
+
vec3 color;
|
|
13
|
+
float roughness;
|
|
14
|
+
float subsurface;
|
|
15
|
+
float sheen;
|
|
16
|
+
float sheenTint;
|
|
17
|
+
float anisotropic;
|
|
18
|
+
float specular;
|
|
19
|
+
float metallicness;
|
|
20
|
+
float specularTint;
|
|
21
|
+
float clearcoat;
|
|
22
|
+
float clearcoatGloss;
|
|
23
|
+
|
|
24
|
+
int hasAlbedoMap;
|
|
25
|
+
vec2 albedoMap;
|
|
26
|
+
int hasNormalMap;
|
|
27
|
+
vec2 normalMap;
|
|
28
|
+
int hasRoughnessMap;
|
|
29
|
+
vec2 roughnessMap;
|
|
30
|
+
int hasAoMap;
|
|
31
|
+
vec2 aoMap;
|
|
32
|
+
};
|
|
33
|
+
in vec2 uv;
|
|
34
|
+
in mat3 TBN;
|
|
35
|
+
|
|
36
|
+
// Material attributes
|
|
37
|
+
flat in Material mtl;
|
|
38
|
+
|
|
39
|
+
// Uniforms
|
|
40
|
+
uniform textArray textureArrays[5];
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
vec3 getNormal(Material mtl, mat3 TBN){
|
|
44
|
+
// Isolate the normal vector from the TBN basis
|
|
45
|
+
vec3 normal = TBN[2];
|
|
46
|
+
// Apply normal map if the material has one
|
|
47
|
+
if (bool(mtl.hasNormalMap)) {
|
|
48
|
+
normal = texture(textureArrays[int(round(mtl.normalMap.x))].array, vec3(uv, round(mtl.normalMap.y))).rgb * 2.0 - 1.0;
|
|
49
|
+
normal = normalize(TBN * normal);
|
|
50
|
+
}
|
|
51
|
+
// Return vector
|
|
52
|
+
return normal;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void main() {
|
|
56
|
+
// Get lighting vectors
|
|
57
|
+
vec3 normal = getNormal(mtl, TBN);
|
|
58
|
+
|
|
59
|
+
// Output fragment color
|
|
60
|
+
fragColor = vec4(normal, 1.0);
|
|
61
|
+
|
|
62
|
+
bloomColor = vec4(0.0);
|
|
60
63
|
}
|
basilisk/shaders/normal.vert
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
#version 330 core
|
|
2
|
-
|
|
3
|
-
layout (location = 0) in vec3 in_position;
|
|
4
|
-
layout (location = 1) in vec2 in_uv;
|
|
5
|
-
layout (location = 2) in vec3 in_normal;
|
|
6
|
-
layout (location = 3) in vec3 in_tangent;
|
|
7
|
-
layout (location = 4) in vec3 in_bitangent;
|
|
8
|
-
|
|
9
|
-
layout (location = 5) in vec3 obj_position;
|
|
10
|
-
layout (location = 6) in vec4 obj_rotation;
|
|
11
|
-
layout (location = 7) in vec3 obj_scale;
|
|
12
|
-
layout (location = 8) in float obj_material;
|
|
13
|
-
|
|
14
|
-
// Variables passed on to the fragment shader
|
|
15
|
-
out vec2 uv;
|
|
16
|
-
out mat3 TBN;
|
|
17
|
-
|
|
18
|
-
// Material struct sent to fragment shader
|
|
19
|
-
struct Material {
|
|
20
|
-
vec3 color;
|
|
21
|
-
float roughness;
|
|
22
|
-
float subsurface;
|
|
23
|
-
float sheen;
|
|
24
|
-
float sheenTint;
|
|
25
|
-
float anisotropic;
|
|
26
|
-
float specular;
|
|
27
|
-
float metallicness;
|
|
28
|
-
float specularTint;
|
|
29
|
-
float clearcoat;
|
|
30
|
-
float clearcoatGloss;
|
|
31
|
-
|
|
32
|
-
int hasAlbedoMap;
|
|
33
|
-
vec2 albedoMap;
|
|
34
|
-
int hasNormalMap;
|
|
35
|
-
vec2 normalMap;
|
|
36
|
-
int hasRoughnessMap;
|
|
37
|
-
vec2 roughnessMap;
|
|
38
|
-
int hasAoMap;
|
|
39
|
-
vec2 aoMap;
|
|
40
|
-
};
|
|
41
|
-
flat out Material mtl;
|
|
42
|
-
|
|
43
|
-
// Uniforms
|
|
44
|
-
uniform mat4 projectionMatrix;
|
|
45
|
-
uniform mat4 viewMatrix;
|
|
46
|
-
uniform sampler2D materialsTexture;
|
|
47
|
-
|
|
48
|
-
// Function to get the model matrix from node position, rotation, and scale
|
|
49
|
-
mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
|
|
50
|
-
mat4 translation = mat4(
|
|
51
|
-
1 , 0 , 0 , 0,
|
|
52
|
-
0 , 1 , 0 , 0,
|
|
53
|
-
0 , 0 , 1 , 0,
|
|
54
|
-
pos.x, pos.y, pos.z, 1
|
|
55
|
-
);
|
|
56
|
-
mat4 rotation = mat4(
|
|
57
|
-
1 - 2 * (rot.z * rot.z + rot.w * rot.w), 2 * (rot.y * rot.z - rot.w * rot.x), 2 * (rot.y * rot.w + rot.z * rot.x), 0,
|
|
58
|
-
2 * (rot.y * rot.z + rot.w * rot.x), 1 - 2 * (rot.y * rot.y + rot.w * rot.w), 2 * (rot.z * rot.w - rot.y * rot.x), 0,
|
|
59
|
-
2 * (rot.y * rot.w - rot.z * rot.x), 2 * (rot.z * rot.w + rot.y * rot.x), 1 - 2 * (rot.y * rot.y + rot.z * rot.z), 0,
|
|
60
|
-
0, 0, 0, 1
|
|
61
|
-
);
|
|
62
|
-
mat4 scale = mat4(
|
|
63
|
-
scl.x, 0 , 0 , 0,
|
|
64
|
-
0 , scl.y, 0 , 0,
|
|
65
|
-
0 , 0 , scl.z, 0,
|
|
66
|
-
0 , 0 , 0 , 1
|
|
67
|
-
);
|
|
68
|
-
return translation * rotation * scale;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Function to get the TBN matrix for normal mapping
|
|
72
|
-
mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
|
|
73
|
-
vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
|
|
74
|
-
vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
|
|
75
|
-
vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
|
|
76
|
-
return mat3(T, B, N);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
void main() {
|
|
80
|
-
// Set the model matrix
|
|
81
|
-
mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
|
|
82
|
-
|
|
83
|
-
// Set out variables
|
|
84
|
-
TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
|
|
85
|
-
uv = in_uv;
|
|
86
|
-
|
|
87
|
-
// Get the material
|
|
88
|
-
int mtl_size = 25;
|
|
89
|
-
mtl = Material(vec3(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, vec2(0), 0, vec2(0), 0, vec2(0), 0, vec2(0));
|
|
90
|
-
int materialID = int(obj_material);
|
|
91
|
-
|
|
92
|
-
mtl.hasNormalMap = int(texelFetch(materialsTexture, ivec2(0, 16 + materialID * mtl_size), 0).r);
|
|
93
|
-
mtl.normalMap = vec2(texelFetch(materialsTexture, ivec2(0, 17 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 18 + materialID * mtl_size), 0).r);
|
|
94
|
-
|
|
95
|
-
// Set the fragment position
|
|
96
|
-
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) in vec3 in_position;
|
|
4
|
+
layout (location = 1) in vec2 in_uv;
|
|
5
|
+
layout (location = 2) in vec3 in_normal;
|
|
6
|
+
layout (location = 3) in vec3 in_tangent;
|
|
7
|
+
layout (location = 4) in vec3 in_bitangent;
|
|
8
|
+
|
|
9
|
+
layout (location = 5) in vec3 obj_position;
|
|
10
|
+
layout (location = 6) in vec4 obj_rotation;
|
|
11
|
+
layout (location = 7) in vec3 obj_scale;
|
|
12
|
+
layout (location = 8) in float obj_material;
|
|
13
|
+
|
|
14
|
+
// Variables passed on to the fragment shader
|
|
15
|
+
out vec2 uv;
|
|
16
|
+
out mat3 TBN;
|
|
17
|
+
|
|
18
|
+
// Material struct sent to fragment shader
|
|
19
|
+
struct Material {
|
|
20
|
+
vec3 color;
|
|
21
|
+
float roughness;
|
|
22
|
+
float subsurface;
|
|
23
|
+
float sheen;
|
|
24
|
+
float sheenTint;
|
|
25
|
+
float anisotropic;
|
|
26
|
+
float specular;
|
|
27
|
+
float metallicness;
|
|
28
|
+
float specularTint;
|
|
29
|
+
float clearcoat;
|
|
30
|
+
float clearcoatGloss;
|
|
31
|
+
|
|
32
|
+
int hasAlbedoMap;
|
|
33
|
+
vec2 albedoMap;
|
|
34
|
+
int hasNormalMap;
|
|
35
|
+
vec2 normalMap;
|
|
36
|
+
int hasRoughnessMap;
|
|
37
|
+
vec2 roughnessMap;
|
|
38
|
+
int hasAoMap;
|
|
39
|
+
vec2 aoMap;
|
|
40
|
+
};
|
|
41
|
+
flat out Material mtl;
|
|
42
|
+
|
|
43
|
+
// Uniforms
|
|
44
|
+
uniform mat4 projectionMatrix;
|
|
45
|
+
uniform mat4 viewMatrix;
|
|
46
|
+
uniform sampler2D materialsTexture;
|
|
47
|
+
|
|
48
|
+
// Function to get the model matrix from node position, rotation, and scale
|
|
49
|
+
mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
|
|
50
|
+
mat4 translation = mat4(
|
|
51
|
+
1 , 0 , 0 , 0,
|
|
52
|
+
0 , 1 , 0 , 0,
|
|
53
|
+
0 , 0 , 1 , 0,
|
|
54
|
+
pos.x, pos.y, pos.z, 1
|
|
55
|
+
);
|
|
56
|
+
mat4 rotation = mat4(
|
|
57
|
+
1 - 2 * (rot.z * rot.z + rot.w * rot.w), 2 * (rot.y * rot.z - rot.w * rot.x), 2 * (rot.y * rot.w + rot.z * rot.x), 0,
|
|
58
|
+
2 * (rot.y * rot.z + rot.w * rot.x), 1 - 2 * (rot.y * rot.y + rot.w * rot.w), 2 * (rot.z * rot.w - rot.y * rot.x), 0,
|
|
59
|
+
2 * (rot.y * rot.w - rot.z * rot.x), 2 * (rot.z * rot.w + rot.y * rot.x), 1 - 2 * (rot.y * rot.y + rot.z * rot.z), 0,
|
|
60
|
+
0, 0, 0, 1
|
|
61
|
+
);
|
|
62
|
+
mat4 scale = mat4(
|
|
63
|
+
scl.x, 0 , 0 , 0,
|
|
64
|
+
0 , scl.y, 0 , 0,
|
|
65
|
+
0 , 0 , scl.z, 0,
|
|
66
|
+
0 , 0 , 0 , 1
|
|
67
|
+
);
|
|
68
|
+
return translation * rotation * scale;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Function to get the TBN matrix for normal mapping
|
|
72
|
+
mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
|
|
73
|
+
vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
|
|
74
|
+
vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
|
|
75
|
+
vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
|
|
76
|
+
return mat3(T, B, N);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void main() {
|
|
80
|
+
// Set the model matrix
|
|
81
|
+
mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
|
|
82
|
+
|
|
83
|
+
// Set out variables
|
|
84
|
+
TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
|
|
85
|
+
uv = in_uv;
|
|
86
|
+
|
|
87
|
+
// Get the material
|
|
88
|
+
int mtl_size = 25;
|
|
89
|
+
mtl = Material(vec3(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, vec2(0), 0, vec2(0), 0, vec2(0), 0, vec2(0));
|
|
90
|
+
int materialID = int(obj_material);
|
|
91
|
+
|
|
92
|
+
mtl.hasNormalMap = int(texelFetch(materialsTexture, ivec2(0, 16 + materialID * mtl_size), 0).r);
|
|
93
|
+
mtl.normalMap = vec2(texelFetch(materialsTexture, ivec2(0, 17 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 18 + materialID * mtl_size), 0).r);
|
|
94
|
+
|
|
95
|
+
// Set the fragment position
|
|
96
|
+
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
|
|
97
97
|
}
|
basilisk/shaders/particle.frag
CHANGED
|
@@ -1,72 +1,77 @@
|
|
|
1
|
-
#version 330 core
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
in
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
float
|
|
19
|
-
float
|
|
20
|
-
float
|
|
21
|
-
float
|
|
22
|
-
float
|
|
23
|
-
float
|
|
24
|
-
float
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
vec3
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) out vec4 fragColor;
|
|
4
|
+
layout (location = 1) out vec4 bloomColor;
|
|
5
|
+
|
|
6
|
+
in vec2 uv;
|
|
7
|
+
in vec3 position;
|
|
8
|
+
in mat3 TBN;
|
|
9
|
+
|
|
10
|
+
struct textArray {
|
|
11
|
+
sampler2DArray array;
|
|
12
|
+
};
|
|
13
|
+
uniform textArray textureArrays[5];
|
|
14
|
+
|
|
15
|
+
struct Material {
|
|
16
|
+
vec3 color;
|
|
17
|
+
vec3 emissiveColor;
|
|
18
|
+
float roughness;
|
|
19
|
+
float subsurface;
|
|
20
|
+
float sheen;
|
|
21
|
+
float sheenTint;
|
|
22
|
+
float anisotropic;
|
|
23
|
+
float specular;
|
|
24
|
+
float metallicness;
|
|
25
|
+
float specularTint;
|
|
26
|
+
float clearcoat;
|
|
27
|
+
float clearcoatGloss;
|
|
28
|
+
|
|
29
|
+
int hasAlbedoMap;
|
|
30
|
+
vec2 albedoMap;
|
|
31
|
+
int hasNormalMap;
|
|
32
|
+
vec2 normalMap;
|
|
33
|
+
int hasRoughnessMap;
|
|
34
|
+
vec2 roughnessMap;
|
|
35
|
+
int hasAoMap;
|
|
36
|
+
vec2 aoMap;
|
|
37
|
+
};
|
|
38
|
+
flat in Material mtl;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
vec3 getColor(Material mtl, vec2 uv, float gamma) {
|
|
42
|
+
vec3 albedo = mtl.color;
|
|
43
|
+
if (bool(mtl.hasAlbedoMap)){
|
|
44
|
+
albedo *= pow(texture(textureArrays[int(round(mtl.albedoMap.x))].array, vec3(uv, round(mtl.albedoMap.y))).rgb, vec3(gamma));
|
|
45
|
+
}
|
|
46
|
+
return albedo;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec3 getNormal(Material mtl, mat3 TBN){
|
|
50
|
+
// Isolate the normal vector from the TBN basis
|
|
51
|
+
vec3 normal = TBN[2];
|
|
52
|
+
// Apply normal map if the material has one
|
|
53
|
+
if (bool(mtl.hasNormalMap)) {
|
|
54
|
+
normal = texture(textureArrays[int(round(mtl.normalMap.x))].array, vec3(uv, round(mtl.normalMap.y))).rgb * 2.0 - 1.0;
|
|
55
|
+
normal = normalize(TBN * normal);
|
|
56
|
+
}
|
|
57
|
+
// Return vector
|
|
58
|
+
return normal;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void main()
|
|
62
|
+
{
|
|
63
|
+
// Texture and normal data
|
|
64
|
+
float gamma = 2.2;
|
|
65
|
+
vec3 color = getColor(mtl, uv, gamma);
|
|
66
|
+
vec3 normal = getNormal(mtl, TBN);
|
|
67
|
+
|
|
68
|
+
// Simple light calculations
|
|
69
|
+
vec3 light = normalize(vec3(1.5, 2, 1));
|
|
70
|
+
float diff = abs(dot(normal, light));
|
|
71
|
+
|
|
72
|
+
// Get color and gamma correction
|
|
73
|
+
fragColor = vec4(color * (.2 + diff), 1.0);
|
|
74
|
+
fragColor.rgb = pow(fragColor.rgb, vec3(1.0/gamma));
|
|
75
|
+
|
|
76
|
+
bloomColor = vec4(mtl.emissiveColor, 1.0);
|
|
72
77
|
}
|