basilisk-engine 0.1.2__py3-none-any.whl → 0.1.3__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.

Files changed (82) hide show
  1. basilisk/__init__.py +11 -11
  2. basilisk/bsk_assets/cube.obj +48 -48
  3. basilisk/collisions/broad/broad_aabb.py +102 -102
  4. basilisk/collisions/broad/broad_bvh.py +137 -137
  5. basilisk/collisions/collider.py +95 -83
  6. basilisk/collisions/collider_handler.py +225 -228
  7. basilisk/collisions/narrow/contact_manifold.py +90 -90
  8. basilisk/collisions/narrow/dataclasses.py +33 -27
  9. basilisk/collisions/narrow/deprecated.py +46 -46
  10. basilisk/collisions/narrow/epa.py +91 -91
  11. basilisk/collisions/narrow/gjk.py +66 -66
  12. basilisk/collisions/narrow/graham_scan.py +24 -24
  13. basilisk/collisions/narrow/helper.py +29 -29
  14. basilisk/collisions/narrow/line_intersections.py +106 -106
  15. basilisk/collisions/narrow/sutherland_hodgman.py +75 -75
  16. basilisk/config.py +2 -2
  17. basilisk/draw/draw.py +100 -100
  18. basilisk/draw/draw_handler.py +180 -210
  19. basilisk/draw/font_renderer.py +28 -28
  20. basilisk/engine.py +195 -195
  21. basilisk/generic/abstract_bvh.py +15 -15
  22. basilisk/generic/abstract_custom.py +133 -133
  23. basilisk/generic/collisions.py +70 -70
  24. basilisk/generic/input_validation.py +67 -28
  25. basilisk/generic/math.py +6 -6
  26. basilisk/generic/matrices.py +33 -33
  27. basilisk/generic/meshes.py +72 -72
  28. basilisk/generic/quat.py +137 -137
  29. basilisk/generic/quat_methods.py +7 -7
  30. basilisk/generic/raycast_result.py +24 -0
  31. basilisk/generic/vec3.py +143 -143
  32. basilisk/input/mouse.py +61 -59
  33. basilisk/mesh/cube.py +33 -33
  34. basilisk/mesh/mesh.py +230 -230
  35. basilisk/mesh/mesh_from_data.py +132 -132
  36. basilisk/mesh/model.py +271 -271
  37. basilisk/mesh/narrow_aabb.py +89 -89
  38. basilisk/mesh/narrow_bvh.py +91 -91
  39. basilisk/mesh/narrow_primative.py +23 -23
  40. basilisk/nodes/helper.py +29 -0
  41. basilisk/nodes/node.py +681 -617
  42. basilisk/nodes/node_handler.py +95 -118
  43. basilisk/particles/particle_handler.py +63 -54
  44. basilisk/particles/particle_renderer.py +87 -87
  45. basilisk/physics/impulse.py +112 -112
  46. basilisk/physics/physics_body.py +43 -43
  47. basilisk/physics/physics_engine.py +35 -35
  48. basilisk/render/batch.py +86 -86
  49. basilisk/render/camera.py +204 -199
  50. basilisk/render/chunk.py +99 -99
  51. basilisk/render/chunk_handler.py +154 -154
  52. basilisk/render/frame.py +181 -181
  53. basilisk/render/image.py +75 -75
  54. basilisk/render/image_handler.py +122 -122
  55. basilisk/render/light.py +96 -96
  56. basilisk/render/light_handler.py +58 -58
  57. basilisk/render/material.py +219 -219
  58. basilisk/render/material_handler.py +135 -135
  59. basilisk/render/shader.py +109 -109
  60. basilisk/render/shader_handler.py +79 -79
  61. basilisk/render/sky.py +120 -120
  62. basilisk/scene.py +250 -210
  63. basilisk/shaders/batch.frag +276 -276
  64. basilisk/shaders/batch.vert +115 -115
  65. basilisk/shaders/draw.frag +21 -21
  66. basilisk/shaders/draw.vert +21 -21
  67. basilisk/shaders/filter.frag +22 -22
  68. basilisk/shaders/frame.frag +12 -12
  69. basilisk/shaders/frame.vert +13 -13
  70. basilisk/shaders/geometry.frag +8 -8
  71. basilisk/shaders/geometry.vert +41 -41
  72. basilisk/shaders/normal.frag +59 -59
  73. basilisk/shaders/normal.vert +96 -96
  74. basilisk/shaders/particle.frag +71 -71
  75. basilisk/shaders/particle.vert +84 -84
  76. basilisk/shaders/sky.frag +9 -9
  77. basilisk/shaders/sky.vert +13 -13
  78. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/METADATA +45 -38
  79. basilisk_engine-0.1.3.dist-info/RECORD +97 -0
  80. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/WHEEL +1 -1
  81. basilisk_engine-0.1.2.dist-info/RECORD +0 -95
  82. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/top_level.txt +0 -0
@@ -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
  }
@@ -1,72 +1,72 @@
1
- #version 330 core
2
- out vec4 fragColor;
3
-
4
- in vec2 uv;
5
- in vec3 position;
6
- in mat3 TBN;
7
-
8
- struct textArray {
9
- sampler2DArray array;
10
- };
11
- uniform textArray textureArrays[5];
12
-
13
- struct Material {
14
- vec3 color;
15
- float roughness;
16
- float subsurface;
17
- float sheen;
18
- float sheenTint;
19
- float anisotropic;
20
- float specular;
21
- float metallicness;
22
- float specularTint;
23
- float clearcoat;
24
- float clearcoatGloss;
25
-
26
- int hasAlbedoMap;
27
- vec2 albedoMap;
28
- int hasNormalMap;
29
- vec2 normalMap;
30
- int hasRoughnessMap;
31
- vec2 roughnessMap;
32
- int hasAoMap;
33
- vec2 aoMap;
34
- };
35
- flat in Material mtl;
36
-
37
-
38
- vec3 getColor(Material mtl, vec2 uv, float gamma) {
39
- vec3 albedo = mtl.color;
40
- if (bool(mtl.hasAlbedoMap)){
41
- albedo *= pow(texture(textureArrays[int(round(mtl.albedoMap.x))].array, vec3(uv, round(mtl.albedoMap.y))).rgb, vec3(gamma));
42
- }
43
- return albedo;
44
- }
45
-
46
- vec3 getNormal(Material mtl, mat3 TBN){
47
- // Isolate the normal vector from the TBN basis
48
- vec3 normal = TBN[2];
49
- // Apply normal map if the material has one
50
- if (bool(mtl.hasNormalMap)) {
51
- normal = texture(textureArrays[int(round(mtl.normalMap.x))].array, vec3(uv, round(mtl.normalMap.y))).rgb * 2.0 - 1.0;
52
- normal = normalize(TBN * normal);
53
- }
54
- // Return vector
55
- return normal;
56
- }
57
-
58
- void main()
59
- {
60
- // Texture and normal data
61
- float gamma = 2.2;
62
- vec3 color = getColor(mtl, uv, gamma);
63
- vec3 normal = getNormal(mtl, TBN);
64
-
65
- // Simple light calculations
66
- vec3 light = normalize(vec3(1.5, 2, 1));
67
- float diff = abs(dot(normal, light));
68
-
69
- // Get color and gamma correction
70
- fragColor = vec4(color * (.2 + diff), 1.0);
71
- fragColor.rgb = pow(fragColor.rgb, vec3(1.0/gamma));
1
+ #version 330 core
2
+ out vec4 fragColor;
3
+
4
+ in vec2 uv;
5
+ in vec3 position;
6
+ in mat3 TBN;
7
+
8
+ struct textArray {
9
+ sampler2DArray array;
10
+ };
11
+ uniform textArray textureArrays[5];
12
+
13
+ struct Material {
14
+ vec3 color;
15
+ float roughness;
16
+ float subsurface;
17
+ float sheen;
18
+ float sheenTint;
19
+ float anisotropic;
20
+ float specular;
21
+ float metallicness;
22
+ float specularTint;
23
+ float clearcoat;
24
+ float clearcoatGloss;
25
+
26
+ int hasAlbedoMap;
27
+ vec2 albedoMap;
28
+ int hasNormalMap;
29
+ vec2 normalMap;
30
+ int hasRoughnessMap;
31
+ vec2 roughnessMap;
32
+ int hasAoMap;
33
+ vec2 aoMap;
34
+ };
35
+ flat in Material mtl;
36
+
37
+
38
+ vec3 getColor(Material mtl, vec2 uv, float gamma) {
39
+ vec3 albedo = mtl.color;
40
+ if (bool(mtl.hasAlbedoMap)){
41
+ albedo *= pow(texture(textureArrays[int(round(mtl.albedoMap.x))].array, vec3(uv, round(mtl.albedoMap.y))).rgb, vec3(gamma));
42
+ }
43
+ return albedo;
44
+ }
45
+
46
+ vec3 getNormal(Material mtl, mat3 TBN){
47
+ // Isolate the normal vector from the TBN basis
48
+ vec3 normal = TBN[2];
49
+ // Apply normal map if the material has one
50
+ if (bool(mtl.hasNormalMap)) {
51
+ normal = texture(textureArrays[int(round(mtl.normalMap.x))].array, vec3(uv, round(mtl.normalMap.y))).rgb * 2.0 - 1.0;
52
+ normal = normalize(TBN * normal);
53
+ }
54
+ // Return vector
55
+ return normal;
56
+ }
57
+
58
+ void main()
59
+ {
60
+ // Texture and normal data
61
+ float gamma = 2.2;
62
+ vec3 color = getColor(mtl, uv, gamma);
63
+ vec3 normal = getNormal(mtl, TBN);
64
+
65
+ // Simple light calculations
66
+ vec3 light = normalize(vec3(1.5, 2, 1));
67
+ float diff = abs(dot(normal, light));
68
+
69
+ // Get color and gamma correction
70
+ fragColor = vec4(color * (.2 + diff), 1.0);
71
+ fragColor.rgb = pow(fragColor.rgb, vec3(1.0/gamma));
72
72
  }
@@ -1,85 +1,85 @@
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
-
10
- in vec3 in_instance_pos;
11
- in float in_instance_mtl;
12
- in float scale;
13
- in float life;
14
-
15
- out vec2 uv;
16
- out mat3 TBN;
17
-
18
- uniform mat4 projectionMatrix;
19
- uniform mat4 viewMatrix;
20
- uniform sampler2D materialsTexture;
21
-
22
- struct Material {
23
- vec3 color;
24
- float roughness;
25
- float subsurface;
26
- float sheen;
27
- float sheenTint;
28
- float anisotropic;
29
- float specular;
30
- float metallicness;
31
- float specularTint;
32
- float clearcoat;
33
- float clearcoatGloss;
34
-
35
- int hasAlbedoMap;
36
- vec2 albedoMap;
37
- int hasNormalMap;
38
- vec2 normalMap;
39
- int hasRoughnessMap;
40
- vec2 roughnessMap;
41
- int hasAoMap;
42
- vec2 aoMap;
43
- };
44
- flat out Material mtl;
45
-
46
- // Function to get the model matrix from node position, rotation, and scale
47
- mat4 getModelMatrix(vec3 pos, float scale) {
48
- mat4 translation = mat4(
49
- scale, 0 , 0 , 0,
50
- 0 , scale, 0 , 0,
51
- 0 , 0 , scale, 0,
52
- pos.x, pos.y, pos.z, 1
53
- );
54
- return translation;
55
- }
56
-
57
- // Function to get the TBN matrix for normal mapping
58
- mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
59
- vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
60
- vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
61
- vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
62
- return mat3(T, B, N);
63
- }
64
-
65
- void main() {
66
- // Set the model matrix
67
- mat4 modelMatrix = getModelMatrix(in_instance_pos, scale * life);
68
-
69
- // Set out variables
70
- TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
71
- uv = in_uv;
72
-
73
- // Material Data
74
- int mtl_size = 25;
75
- int materialID = int(in_instance_mtl);
76
- 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));
77
- mtl.color = vec3(texelFetch(materialsTexture, ivec2(0, 0 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 1 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 2 + materialID * mtl_size), 0).r);
78
- mtl.hasAlbedoMap = int(texelFetch(materialsTexture, ivec2(0, 13 + materialID * mtl_size), 0).r);
79
- mtl.albedoMap = vec2(texelFetch(materialsTexture, ivec2(0, 14 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 15 + materialID * mtl_size), 0).r);
80
- mtl.hasNormalMap = int(texelFetch(materialsTexture, ivec2(0, 16 + materialID * mtl_size), 0).r);
81
- mtl.normalMap = vec2(texelFetch(materialsTexture, ivec2(0, 17 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 18 + materialID * mtl_size), 0).r);
82
-
83
- // Send position to the frag
84
- 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
+
10
+ in vec3 in_instance_pos;
11
+ in float in_instance_mtl;
12
+ in float scale;
13
+ in float life;
14
+
15
+ out vec2 uv;
16
+ out mat3 TBN;
17
+
18
+ uniform mat4 projectionMatrix;
19
+ uniform mat4 viewMatrix;
20
+ uniform sampler2D materialsTexture;
21
+
22
+ struct Material {
23
+ vec3 color;
24
+ float roughness;
25
+ float subsurface;
26
+ float sheen;
27
+ float sheenTint;
28
+ float anisotropic;
29
+ float specular;
30
+ float metallicness;
31
+ float specularTint;
32
+ float clearcoat;
33
+ float clearcoatGloss;
34
+
35
+ int hasAlbedoMap;
36
+ vec2 albedoMap;
37
+ int hasNormalMap;
38
+ vec2 normalMap;
39
+ int hasRoughnessMap;
40
+ vec2 roughnessMap;
41
+ int hasAoMap;
42
+ vec2 aoMap;
43
+ };
44
+ flat out Material mtl;
45
+
46
+ // Function to get the model matrix from node position, rotation, and scale
47
+ mat4 getModelMatrix(vec3 pos, float scale) {
48
+ mat4 translation = mat4(
49
+ scale, 0 , 0 , 0,
50
+ 0 , scale, 0 , 0,
51
+ 0 , 0 , scale, 0,
52
+ pos.x, pos.y, pos.z, 1
53
+ );
54
+ return translation;
55
+ }
56
+
57
+ // Function to get the TBN matrix for normal mapping
58
+ mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
59
+ vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
60
+ vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
61
+ vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
62
+ return mat3(T, B, N);
63
+ }
64
+
65
+ void main() {
66
+ // Set the model matrix
67
+ mat4 modelMatrix = getModelMatrix(in_instance_pos, scale * life);
68
+
69
+ // Set out variables
70
+ TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
71
+ uv = in_uv;
72
+
73
+ // Material Data
74
+ int mtl_size = 25;
75
+ int materialID = int(in_instance_mtl);
76
+ 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));
77
+ mtl.color = vec3(texelFetch(materialsTexture, ivec2(0, 0 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 1 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 2 + materialID * mtl_size), 0).r);
78
+ mtl.hasAlbedoMap = int(texelFetch(materialsTexture, ivec2(0, 13 + materialID * mtl_size), 0).r);
79
+ mtl.albedoMap = vec2(texelFetch(materialsTexture, ivec2(0, 14 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 15 + materialID * mtl_size), 0).r);
80
+ mtl.hasNormalMap = int(texelFetch(materialsTexture, ivec2(0, 16 + materialID * mtl_size), 0).r);
81
+ mtl.normalMap = vec2(texelFetch(materialsTexture, ivec2(0, 17 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 18 + materialID * mtl_size), 0).r);
82
+
83
+ // Send position to the frag
84
+ gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
85
85
  }
basilisk/shaders/sky.frag CHANGED
@@ -1,10 +1,10 @@
1
- #version 330 core
2
- out vec4 fragColor;
3
-
4
- in vec3 texCubeCoords;
5
-
6
- uniform samplerCube skyboxTexture;
7
-
8
- void main() {
9
- fragColor = texture(skyboxTexture, texCubeCoords);
1
+ #version 330 core
2
+ out vec4 fragColor;
3
+
4
+ in vec3 texCubeCoords;
5
+
6
+ uniform samplerCube skyboxTexture;
7
+
8
+ void main() {
9
+ fragColor = texture(skyboxTexture, texCubeCoords);
10
10
  }
basilisk/shaders/sky.vert CHANGED
@@ -1,14 +1,14 @@
1
- #version 330 core
2
- layout (location = 0) in vec3 in_position;
3
-
4
- out vec3 texCubeCoords;
5
-
6
- uniform mat4 projectionMatrix;
7
- uniform mat4 viewMatrix;
8
-
9
- void main() {
10
- texCubeCoords = in_position;
11
- vec4 pos = projectionMatrix * mat4(mat3(viewMatrix)) * vec4(in_position, 1.0);
12
- gl_Position = pos.xyww;
13
- gl_Position.z -= 0.0001;
1
+ #version 330 core
2
+ layout (location = 0) in vec3 in_position;
3
+
4
+ out vec3 texCubeCoords;
5
+
6
+ uniform mat4 projectionMatrix;
7
+ uniform mat4 viewMatrix;
8
+
9
+ void main() {
10
+ texCubeCoords = in_position;
11
+ vec4 pos = projectionMatrix * mat4(mat3(viewMatrix)) * vec4(in_position, 1.0);
12
+ gl_Position = pos.xyww;
13
+ gl_Position.z -= 0.0001;
14
14
  }
@@ -1,38 +1,45 @@
1
- Metadata-Version: 2.1
2
- Name: basilisk-engine
3
- Version: 0.1.2
4
- Summary: Python 3D Framework
5
- Home-page: https://basilisk-website.vercel.app/
6
- Author: Name
7
- Author-email: basiliskengine@gmail.com
8
- Description-Content-Type: text/markdown
9
- Requires-Dist: numpy
10
- Requires-Dist: pillow
11
- Requires-Dist: pygame-ce
12
- Requires-Dist: moderngl
13
- Requires-Dist: PyGLM
14
- Requires-Dist: numba
15
-
16
- # Basilisk Engine
17
- ![image](https://github.com/user-attachments/assets/5e39445c-e0da-452c-9f18-e590cca948c4)
18
- Basilisk Engine is a Python package for effortless 3D rendering and simulation.
19
-
20
- ## Learn more at the [Basilisk Engine Website](https://basilisk-website.vercel.app)
21
-
22
- # Features
23
- ## Rendering
24
- Basilisk Engine uses a versatile and efficient physically based rendering pipeline, allowing for photorealistic and stylized rendering in real-time.
25
-
26
- <p align="center">
27
- <img src="images/mud.png" alt="mud" width="400"/>
28
- <img src="images/foil.png" alt="foil" width="400"/>
29
- <img src="images/cloth.png" alt="mud" width="400"/>
30
- <img src="images/floor.png" alt="mud" width="400"/>
31
- </p>
32
-
33
- ## Physics
34
-
35
- ## Performance
36
-
37
- # Getting Started
38
- ...
1
+ Metadata-Version: 2.2
2
+ Name: basilisk-engine
3
+ Version: 0.1.3
4
+ Summary: Python 3D Framework
5
+ Home-page: https://basilisk-website.vercel.app/
6
+ Author: Name
7
+ Author-email: basiliskengine@gmail.com
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: numpy
10
+ Requires-Dist: pillow
11
+ Requires-Dist: pygame-ce
12
+ Requires-Dist: moderngl
13
+ Requires-Dist: PyGLM
14
+ Requires-Dist: numba
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: requires-dist
21
+ Dynamic: summary
22
+
23
+ # Basilisk Engine
24
+ ![image](https://github.com/user-attachments/assets/5e39445c-e0da-452c-9f18-e590cca948c4)
25
+ Basilisk Engine is a Python package for effortless 3D rendering and simulation.
26
+
27
+ ## Learn more at the [Basilisk Engine Website](https://basilisk-website.vercel.app)
28
+
29
+ # Features
30
+ ## Rendering
31
+ Basilisk Engine uses a versatile and efficient physically based rendering pipeline, allowing for photorealistic and stylized rendering in real-time.
32
+
33
+ <p align="center">
34
+ <img src="images/mud.png" alt="mud" width="400"/>
35
+ <img src="images/foil.png" alt="foil" width="400"/>
36
+ <img src="images/cloth.png" alt="mud" width="400"/>
37
+ <img src="images/floor.png" alt="mud" width="400"/>
38
+ </p>
39
+
40
+ ## Physics
41
+
42
+ ## Performance
43
+
44
+ # Getting Started
45
+ ...