basilisk-engine 0.0.9__py3-none-any.whl → 0.1.1__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 (61) hide show
  1. basilisk/__init__.py +3 -1
  2. basilisk/collisions/broad/broad_aabb.py +8 -1
  3. basilisk/collisions/broad/broad_bvh.py +38 -2
  4. basilisk/collisions/collider.py +20 -10
  5. basilisk/collisions/collider_handler.py +97 -32
  6. basilisk/collisions/narrow/contact_manifold.py +91 -0
  7. basilisk/collisions/narrow/dataclasses.py +27 -0
  8. basilisk/collisions/narrow/deprecated.py +47 -0
  9. basilisk/collisions/narrow/epa.py +21 -15
  10. basilisk/collisions/narrow/gjk.py +15 -14
  11. basilisk/collisions/narrow/graham_scan.py +25 -0
  12. basilisk/collisions/narrow/helper.py +14 -7
  13. basilisk/collisions/narrow/line_intersections.py +107 -0
  14. basilisk/collisions/narrow/sutherland_hodgman.py +76 -0
  15. basilisk/draw/draw_handler.py +7 -5
  16. basilisk/engine.py +28 -6
  17. basilisk/generic/abstract_custom.py +134 -0
  18. basilisk/generic/collisions.py +47 -2
  19. basilisk/generic/quat.py +84 -65
  20. basilisk/generic/vec3.py +99 -67
  21. basilisk/input/mouse.py +3 -3
  22. basilisk/mesh/cube.py +20 -2
  23. basilisk/mesh/mesh.py +69 -54
  24. basilisk/mesh/mesh_from_data.py +106 -21
  25. basilisk/mesh/narrow_aabb.py +10 -1
  26. basilisk/mesh/narrow_bvh.py +9 -1
  27. basilisk/nodes/node.py +211 -101
  28. basilisk/nodes/node_handler.py +58 -33
  29. basilisk/particles/__init__.py +0 -0
  30. basilisk/particles/particle_handler.py +55 -0
  31. basilisk/particles/particle_renderer.py +87 -0
  32. basilisk/physics/impulse.py +113 -0
  33. basilisk/physics/physics_body.py +10 -2
  34. basilisk/physics/physics_engine.py +2 -3
  35. basilisk/render/batch.py +3 -1
  36. basilisk/render/camera.py +35 -1
  37. basilisk/render/chunk.py +19 -4
  38. basilisk/render/chunk_handler.py +39 -23
  39. basilisk/render/image.py +1 -1
  40. basilisk/render/image_handler.py +17 -14
  41. basilisk/render/light_handler.py +16 -11
  42. basilisk/render/material.py +38 -14
  43. basilisk/render/material_handler.py +31 -18
  44. basilisk/render/shader.py +110 -0
  45. basilisk/render/shader_handler.py +20 -35
  46. basilisk/render/sky.py +8 -5
  47. basilisk/scene.py +116 -33
  48. basilisk/shaders/batch.frag +40 -11
  49. basilisk/shaders/batch.vert +14 -7
  50. basilisk/shaders/geometry.frag +9 -0
  51. basilisk/shaders/geometry.vert +42 -0
  52. basilisk/shaders/normal.frag +60 -0
  53. basilisk/shaders/normal.vert +97 -0
  54. basilisk/shaders/particle.frag +72 -0
  55. basilisk/shaders/particle.vert +85 -0
  56. {basilisk_engine-0.0.9.dist-info → basilisk_engine-0.1.1.dist-info}/METADATA +5 -5
  57. basilisk_engine-0.1.1.dist-info/RECORD +95 -0
  58. basilisk/shaders/image.png +0 -0
  59. basilisk_engine-0.0.9.dist-info/RECORD +0 -78
  60. {basilisk_engine-0.0.9.dist-info → basilisk_engine-0.1.1.dist-info}/WHEEL +0 -0
  61. {basilisk_engine-0.0.9.dist-info → basilisk_engine-0.1.1.dist-info}/top_level.txt +0 -0
@@ -31,6 +31,10 @@ struct Material {
31
31
  vec2 albedoMap;
32
32
  int hasNormalMap;
33
33
  vec2 normalMap;
34
+ int hasRoughnessMap;
35
+ vec2 roughnessMap;
36
+ int hasAoMap;
37
+ vec2 aoMap;
34
38
  };
35
39
 
36
40
  struct LightResult {
@@ -92,7 +96,7 @@ float AnisotropicSmithGGX(float ndots, float sdotx, float sdoty, float ax, float
92
96
 
93
97
  // Diffuse model as outlined by Burley: https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
94
98
  // Much help from Acerola's video on the topic: https://www.youtube.com/watch?v=KkOkx0FiHDA&t=570s
95
- LightResult PrincipledDiffuse(DirectionalLight light, Material mtl, vec3 albedo, vec3 N, vec3 V, vec3 X, vec3 Y) {
99
+ LightResult PrincipledDiffuse(DirectionalLight light, Material mtl, vec3 albedo, float roughness, vec3 N, vec3 V, vec3 X, vec3 Y) {
96
100
 
97
101
  LightResult result;
98
102
 
@@ -123,7 +127,7 @@ LightResult PrincipledDiffuse(DirectionalLight light, Material mtl, vec3 albedo,
123
127
  // Diffuse
124
128
  float FL = SchlickFresnel(cos_theta_l);
125
129
  float FV = SchlickFresnel(cos_theta_V);
126
- float Fss90 = cos_theta_D * cos_theta_D * mtl.roughness;
130
+ float Fss90 = cos_theta_D * cos_theta_D * roughness;
127
131
  float Fd90 = 0.5 + 2.0 * Fss90;
128
132
 
129
133
  float Fd = mix(1.0, Fd90, FL) * mix(1.0, Fd90, FV);
@@ -133,7 +137,7 @@ LightResult PrincipledDiffuse(DirectionalLight light, Material mtl, vec3 albedo,
133
137
  float ss = 1.25 * (Fss * ((1 / (cos_theta_l + cos_theta_V)) - 0.5) + 0.5);
134
138
 
135
139
  // Specular
136
- float alpha = mtl.roughness * mtl.roughness;
140
+ float alpha = roughness * roughness;
137
141
  float aspect = sqrt(1.0 - 0.9 * mtl.anisotropic);
138
142
  float alpha_x = max(0.001, alpha / aspect);
139
143
  float alpha_y = max(0.001, alpha * aspect);
@@ -143,7 +147,7 @@ LightResult PrincipledDiffuse(DirectionalLight light, Material mtl, vec3 albedo,
143
147
  float Ds = AnisotropicGTR2(ndoth, hdotx, hdoty, alpha_x, alpha_y);
144
148
 
145
149
  // Geometric Attenuation
146
- float GalphaSquared = pow(0.5 + mtl.roughness * 0.5, 2);
150
+ float GalphaSquared = pow(0.5 + roughness * 0.5, 2);
147
151
  float GalphaX = max(0.001, GalphaSquared / aspect);
148
152
  float GalphaY = max(0.001, GalphaSquared * aspect);
149
153
  float G = AnisotropicSmithGGX(cos_theta_l, ldotx, ldoty, GalphaX, GalphaY);
@@ -192,15 +196,39 @@ vec3 getNormal(Material mtl, mat3 TBN){
192
196
  return normal;
193
197
  }
194
198
 
199
+ float getAo(Material mtl, vec2 uv) {
200
+ float ao;
201
+ if (bool(mtl.hasAoMap)){
202
+ ao = texture(textureArrays[int(round(mtl.aoMap.x))].array, vec3(uv, round(mtl.aoMap.y))).a;
203
+ }
204
+ else {
205
+ ao = 1.0;
206
+ }
207
+ return ao;
208
+ }
209
+
210
+ float getRoughness(Material mtl, vec2 uv) {
211
+ float roughness;
212
+ if (bool(mtl.hasRoughnessMap)){
213
+ roughness = texture(textureArrays[int(round(mtl.roughnessMap.x))].array, vec3(uv, round(mtl.roughnessMap.y))).a;
214
+ }
215
+ else {
216
+ roughness = mtl.roughness;
217
+ }
218
+ return roughness;
219
+ }
220
+
195
221
  void main() {
196
222
  float gamma = 2.2;
197
223
  vec3 viewDir = vec3(normalize(cameraPosition - position));
198
224
 
199
225
  // Get lighting vectors
200
- vec3 albedo = getAlbedo(mtl, uv, gamma);
201
- vec3 normal = getNormal(mtl, TBN);
202
- vec3 tangent = TBN[0];
203
- vec3 bitangent = TBN[1];
226
+ vec3 albedo = getAlbedo(mtl, uv, gamma);
227
+ vec3 normal = getNormal(mtl, TBN);
228
+ float ao = getAo(mtl, uv);
229
+ float roughness = getRoughness(mtl, uv);
230
+ vec3 tangent = TBN[0];
231
+ vec3 bitangent = TBN[1];
204
232
 
205
233
  // Orthogonalize the tangent and bitangent according to the mapped normal vector
206
234
  tangent = tangent - dot(normal, tangent) * normal;
@@ -224,17 +252,18 @@ void main() {
224
252
  // Add result from each directional light in the scene
225
253
  for (int i = 0; i < numDirLights; i++) {
226
254
  // Caculate the light for the directional light
227
- LightResult dirLightResult = PrincipledDiffuse(dirLights[i], mtl, albedo, N, V, X, Y);
255
+ LightResult dirLightResult = PrincipledDiffuse(dirLights[i], mtl, albedo, roughness, N, V, X, Y);
228
256
  vec3 lightFactor = dirLights[i].intensity * dirLights[i].color;
229
257
  // Add each lobe
230
- lightResult.diffuse += dirLightResult.diffuse * lightFactor;
231
- lightResult.specular += dirLightResult.specular * lightFactor;
258
+ lightResult.diffuse += dirLightResult.diffuse * lightFactor;
259
+ lightResult.specular += dirLightResult.specular * lightFactor;
232
260
  lightResult.clearcoat += dirLightResult.clearcoat * lightFactor;
233
261
  }
234
262
 
235
263
  lightResult.specular = min(vec3(1.0), lightResult.specular);
236
264
  lightResult.specular *= mix(vec3(1.0), reflect_sky, mtl.metallicness) * luminance(reflect_sky);
237
265
  lightResult.diffuse *= mix(vec3(1.0), ambient_sky, 0.25);
266
+ lightResult.diffuse *= ao;
238
267
 
239
268
  vec3 finalColor = albedo * 0.3 * mix(vec3(1.0), reflect_sky, mtl.metallicness);
240
269
  finalColor += (lightResult.diffuse + lightResult.specular + lightResult.clearcoat);
@@ -34,6 +34,10 @@ struct Material {
34
34
  vec2 albedoMap;
35
35
  int hasNormalMap;
36
36
  vec2 normalMap;
37
+ int hasRoughnessMap;
38
+ vec2 roughnessMap;
39
+ int hasAoMap;
40
+ vec2 aoMap;
37
41
  };
38
42
  flat out Material mtl;
39
43
 
@@ -83,11 +87,10 @@ void main() {
83
87
  uv = in_uv;
84
88
 
85
89
  // Get the material
86
- int mtl_size = 19;
90
+ int mtl_size = 25;
87
91
  int materialID = int(obj_material);
92
+
88
93
  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);
89
-
90
-
91
94
  mtl.roughness = texelFetch(materialsTexture, ivec2(0, 3 + materialID * mtl_size), 0).r;
92
95
  mtl.subsurface = texelFetch(materialsTexture, ivec2(0, 4 + materialID * mtl_size), 0).r;
93
96
  mtl.sheen = texelFetch(materialsTexture, ivec2(0, 5 + materialID * mtl_size), 0).r;
@@ -99,10 +102,14 @@ void main() {
99
102
  mtl.clearcoat = texelFetch(materialsTexture, ivec2(0, 11 + materialID * mtl_size), 0).r;
100
103
  mtl.clearcoatGloss = texelFetch(materialsTexture, ivec2(0, 12 + materialID * mtl_size), 0).r;
101
104
 
102
- mtl.hasAlbedoMap = int(texelFetch(materialsTexture, ivec2(0, 13 + materialID * mtl_size), 0).r);
103
- mtl.albedoMap = vec2(texelFetch(materialsTexture, ivec2(0, 14 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 15 + materialID * mtl_size), 0).r);
104
- mtl.hasNormalMap = int(texelFetch(materialsTexture, ivec2(0, 16 + materialID * mtl_size), 0).r);
105
- mtl.normalMap = vec2(texelFetch(materialsTexture, ivec2(0, 17 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 18 + materialID * mtl_size), 0).r);
105
+ mtl.hasAlbedoMap = int(texelFetch(materialsTexture, ivec2(0, 13 + materialID * mtl_size), 0).r);
106
+ mtl.albedoMap = vec2(texelFetch(materialsTexture, ivec2(0, 14 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 15 + materialID * mtl_size), 0).r);
107
+ mtl.hasNormalMap = int(texelFetch(materialsTexture, ivec2(0, 16 + materialID * mtl_size), 0).r);
108
+ mtl.normalMap = vec2(texelFetch(materialsTexture, ivec2(0, 17 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 18 + materialID * mtl_size), 0).r);
109
+ mtl.hasRoughnessMap = int(texelFetch(materialsTexture, ivec2(0, 19 + materialID * mtl_size), 0).r);
110
+ mtl.roughnessMap = vec2(texelFetch(materialsTexture, ivec2(0, 20 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 21 + materialID * mtl_size), 0).r);
111
+ mtl.hasAoMap = int(texelFetch(materialsTexture, ivec2(0, 22 + materialID * mtl_size), 0).r);
112
+ mtl.aoMap = vec2(texelFetch(materialsTexture, ivec2(0, 23 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 24 + materialID * mtl_size), 0).r);
106
113
 
107
114
  // Set the fragment position
108
115
  gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
@@ -0,0 +1,9 @@
1
+ #version 330 core
2
+
3
+ layout (location = 0) out vec4 fragColor;
4
+
5
+
6
+ void main() {
7
+ // Output fragment color
8
+ fragColor = vec4(1.0, 1.0, 1.0, 1.0);
9
+ }
@@ -0,0 +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);
42
+ }
@@ -0,0 +1,60 @@
1
+ #version 330 core
2
+
3
+ layout (location = 0) out vec4 fragColor;
4
+
5
+ // Structs needed for the shader
6
+ struct textArray {
7
+ sampler2DArray array;
8
+ };
9
+
10
+ struct Material {
11
+ vec3 color;
12
+ float roughness;
13
+ float subsurface;
14
+ float sheen;
15
+ float sheenTint;
16
+ float anisotropic;
17
+ float specular;
18
+ float metallicness;
19
+ float specularTint;
20
+ float clearcoat;
21
+ float clearcoatGloss;
22
+
23
+ int hasAlbedoMap;
24
+ vec2 albedoMap;
25
+ int hasNormalMap;
26
+ vec2 normalMap;
27
+ int hasRoughnessMap;
28
+ vec2 roughnessMap;
29
+ int hasAoMap;
30
+ vec2 aoMap;
31
+ };
32
+ in vec2 uv;
33
+ in mat3 TBN;
34
+
35
+ // Material attributes
36
+ flat in Material mtl;
37
+
38
+ // Uniforms
39
+ uniform textArray textureArrays[5];
40
+
41
+
42
+ vec3 getNormal(Material mtl, mat3 TBN){
43
+ // Isolate the normal vector from the TBN basis
44
+ vec3 normal = TBN[2];
45
+ // Apply normal map if the material has one
46
+ if (bool(mtl.hasNormalMap)) {
47
+ normal = texture(textureArrays[int(round(mtl.normalMap.x))].array, vec3(uv, round(mtl.normalMap.y))).rgb * 2.0 - 1.0;
48
+ normal = normalize(TBN * normal);
49
+ }
50
+ // Return vector
51
+ return normal;
52
+ }
53
+
54
+ void main() {
55
+ // Get lighting vectors
56
+ vec3 normal = getNormal(mtl, TBN);
57
+
58
+ // Output fragment color
59
+ fragColor = vec4(normal, 1.0);
60
+ }
@@ -0,0 +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);
97
+ }
@@ -0,0 +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));
72
+ }
@@ -0,0 +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);
85
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: basilisk-engine
3
- Version: 0.0.9
3
+ Version: 0.1.1
4
4
  Summary: Python 3D Framework
5
5
  Home-page: https://basilisk-website.vercel.app/
6
6
  Author: Name
@@ -24,10 +24,10 @@ Basilisk Engine is a Python package for effortless 3D rendering and simulation.
24
24
  Basilisk Engine uses a versatile and efficient physically based rendering pipeline, allowing for photorealistic and stylized rendering in real-time.
25
25
 
26
26
  <p align="center">
27
- <img src="mud.png" alt="mud" width="400"/>
28
- <img src="foil.png" alt="foil" width="400"/>
29
- <img src="cloth.png" alt="mud" width="400"/>
30
- <img src="floor.png" alt="mud" width="400"/>
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
31
  </p>
32
32
 
33
33
  ## Physics
@@ -0,0 +1,95 @@
1
+ basilisk/__init__.py,sha256=FF8VVbZ74c3pj8Yg4rGmuAeuFGc00-MdCeic7lx5R8E,422
2
+ basilisk/config.py,sha256=ynTRlX633DGoEtZOeAK8KNJF6offV3k3XFD7cia3Keg,61
3
+ basilisk/engine.py,sha256=0tMlCyNhAZPm7Lq5vXCJmyv--lvOReeIh61KCdQMrD0,6551
4
+ basilisk/scene.py,sha256=vSXCv-wc6OLO3vax03RLB7Gt6xaoCr_S5TZVxefRMp4,8324
5
+ basilisk/bsk_assets/Roboto-Regular.ttf,sha256=kqYnZjMRQMpbyLulIChCLSdgYa1XF8GsUIoRi2Gcauw,168260
6
+ basilisk/bsk_assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ basilisk/bsk_assets/basilisk.png,sha256=1xePD8qDycxlRQ7hjEmfuw900BRykhRyumJePi6hxi8,21299
8
+ basilisk/bsk_assets/cube.obj,sha256=rLm2nNcfj1zPZUx-VSF5CxqnToteHjzXQNxfRNq5iKU,1189
9
+ basilisk/bsk_assets/skybox.png,sha256=0C9MvWUwNzewyiMtWLKrZJzAcLC1Ce72T3-Lq4hJZu0,1206153
10
+ basilisk/collisions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ basilisk/collisions/collider.py,sha256=pg1oVzxrtOkp-rO0ltBKzBY6jXrbi7MS7fIfsyJskFI,3945
12
+ basilisk/collisions/collider_handler.py,sha256=dPC11sznqHDK2UmXNXrcq6UP7qngeRJER-XnQqn6Hmk,11616
13
+ basilisk/collisions/broad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ basilisk/collisions/broad/broad_aabb.py,sha256=cyBCFFFkMY0yNDqBUY0HZ711m3QSSzoW2Ao9f8cFshE,4708
15
+ basilisk/collisions/broad/broad_bvh.py,sha256=M7sMYRzxAwjIu_nkYKrL8HW3YxzBvfrSN1qKClNY568,5127
16
+ basilisk/collisions/narrow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ basilisk/collisions/narrow/contact_manifold.py,sha256=rBqFAKvCR8ksYs54GkjZf8GVzN7hoJ6ZLbjd4bDd39Q,4819
18
+ basilisk/collisions/narrow/dataclasses.py,sha256=RFMwSy2q5VGtN36qMT0Qn6LeNEwBrp28aogGQExAyeQ,803
19
+ basilisk/collisions/narrow/deprecated.py,sha256=yQh6VOoVcwYENU4TThk_pXPSmwT3EfxMKILVR43sEDI,2751
20
+ basilisk/collisions/narrow/epa.py,sha256=kzKRs62kpTDqIqPz7Te1SV6OGWmfFb9Z7kZ1PqAMEwQ,4711
21
+ basilisk/collisions/narrow/gjk.py,sha256=lncqQ4ZkmSa-wPlAUpkdzdSdbiJjiYKDTqqGSr9xRGc,3338
22
+ basilisk/collisions/narrow/graham_scan.py,sha256=4cpsK2qbvLPw09LGXZp779Z536B-bpQciF-atZ4ngEI,862
23
+ basilisk/collisions/narrow/helper.py,sha256=n_ZPGxKhkbubam5ya-OiUiLLejRVl9kdKbN19-_IiKY,1238
24
+ basilisk/collisions/narrow/line_intersections.py,sha256=CGtttZ6n51u4l8JtQXzkClgZ_uvgx9IyrrGqli6JDbI,4629
25
+ basilisk/collisions/narrow/sutherland_hodgman.py,sha256=SUjSU5y7AuzIDiljMcTXxlGuFHT5IwtrOJ_k5HS1S2Y,3140
26
+ basilisk/draw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ basilisk/draw/draw.py,sha256=S1eMkuOiM2M0GQTxb1LgFMX7OCDn3YsUCkNc6-t-ClU,3631
28
+ basilisk/draw/draw_handler.py,sha256=kWIvocGY6-1gnqx-yEIGDEVSPURcLzfGYZs4WS7s0oY,7629
29
+ basilisk/draw/font_renderer.py,sha256=gyI59fW3DUswIcSg5VJLLcJti3OLTMdXNQrYJaw18dE,1092
30
+ basilisk/generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ basilisk/generic/abstract_bvh.py,sha256=iQ6HjcI8Msw34dZ3YuDAhWSqEc4NTBHAaGqAZZAoLL8,383
32
+ basilisk/generic/abstract_custom.py,sha256=EPE2_2OxXyrx1YYO3niSxQ05ocxXnbAmFo7fr121Zxk,4537
33
+ basilisk/generic/collisions.py,sha256=N0A2eShH4wkXXvYQcFB_dTTouYxQs51qb3CpWDyxiak,2659
34
+ basilisk/generic/input_validation.py,sha256=-N2q1S1MMsrwBR9617waBe2VTVx4G3hkfVrN7bVB60o,1325
35
+ basilisk/generic/math.py,sha256=_MfMdu1t0JIdGplGnU9_Tj4ECuxhSNmauLg8zw1zcNs,176
36
+ basilisk/generic/matrices.py,sha256=NNvD0m6Y8lZLa5m6TeXI9k_pMJH0Bo2recL8eVqKjvo,1254
37
+ basilisk/generic/meshes.py,sha256=0Zq5EkWEtqz-2V-kEQt-R3JZvUS5RTqflih8Mj9vL4o,2639
38
+ basilisk/generic/quat.py,sha256=2yXZ5x1GjWQRCui0XDFITGWl9cf3W1KxTtMYfNMbU64,5110
39
+ basilisk/generic/quat_methods.py,sha256=FFqS2Iy1OLH6oJf1elhH9RbWiE_KMXe5eO95ayrEhbc,241
40
+ basilisk/generic/vec3.py,sha256=n_OAVVFtzH-ctqU8Pqhs2426MQ0WOgBbq2Lfo3Nt498,5280
41
+ basilisk/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ basilisk/input/mouse.py,sha256=ReFzNjGpmmNnoyypLZXlG1TV380Y1tpQMqtKXfrxYcY,1900
43
+ basilisk/mesh/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
+ basilisk/mesh/cube.py,sha256=UAwjEmaoWfUdtSKjxATU6vUbksDYj7_bBIr1k1xDsYc,1077
45
+ basilisk/mesh/mesh.py,sha256=vujJ0VxwCvvIKBAScPzo8nWWAouyRzE97M4-JVpqco0,9782
46
+ basilisk/mesh/mesh_from_data.py,sha256=uP7acL2jLELHCVCPgXMKzbSuluZL6azgJyn_VDanjM4,4425
47
+ basilisk/mesh/model.py,sha256=uVnYm_XYSoZslNWmOego59Ku-gqKxZHpta_dHi65X1s,11993
48
+ basilisk/mesh/narrow_aabb.py,sha256=0lc06JgdfhUbzxUnCz4dcbEYSB3xjAf7DY7ec2096is,3868
49
+ basilisk/mesh/narrow_bvh.py,sha256=jLQhmUNi6mFyU2wVwB_SOf4PIaOAygBTtcnQIyaMOGg,4351
50
+ basilisk/mesh/narrow_primative.py,sha256=vWpIeo8I9le-EAvcr9rFUQlbl9mi6eYroqCSMK-m9eY,953
51
+ basilisk/nodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
+ basilisk/nodes/node.py,sha256=ZrXv8bsM8Q_7CTuhRoRFXmVn3ZPsmvMgvLo-VxbcnYc,28529
53
+ basilisk/nodes/node_handler.py,sha256=CWSD5aE7WeqkmTtd1zdObfpp1OlOzptLi705mWUt_nY,6148
54
+ basilisk/particles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
+ basilisk/particles/particle_handler.py,sha256=NlgY8pC3lEOfCqouLOJ4mRUBTGbBmCyDiFAp2hlcB2I,2413
56
+ basilisk/particles/particle_renderer.py,sha256=3OpkKLw4NUik4stORqMkCx1vqibXkdYVq0NDDjigAdo,3623
57
+ basilisk/physics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
+ basilisk/physics/impulse.py,sha256=zv6MoGTSlu8qVbsbe2QxERGeyQZYbtzR_WVSqVLsmhw,5873
59
+ basilisk/physics/physics_body.py,sha256=_mi-AVMgQqUsC3bQIca5tgk2xWXTIUw0D_uC4DcQqqs,1508
60
+ basilisk/physics/physics_engine.py,sha256=IPMshr4j5TII5JdcRqiULc6BfkeCLPxdICKqQeZGAtY,1735
61
+ basilisk/render/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
+ basilisk/render/batch.py,sha256=Vmsm7zA2xi2xE4KKutxkasYfhnRNfyF8CI_HBIZNBIc,2998
63
+ basilisk/render/camera.py,sha256=2LykskC-Xk6gXwYk0SWnzl0jzQxJCvPOWXYNASx9Ykk,7332
64
+ basilisk/render/chunk.py,sha256=YNtoXrZN175u0USSCkpO3_0FiMrBIoaqMZl9XAoJLAA,2656
65
+ basilisk/render/chunk_handler.py,sha256=-vlrlEDqZIoBom2YK8c1yu9sGb7AHH-IbkI4IWYYd5Y,6168
66
+ basilisk/render/frame.py,sha256=OwgDtBK3EtXTD8e6o8chAl0Wu3fg-KwTEYQg1-r21y8,6728
67
+ basilisk/render/image.py,sha256=_VB9e_2iRrjIQGS9cQa9V0xJ42x29AtYsu6GHSWLRRQ,2625
68
+ basilisk/render/image_handler.py,sha256=T_rByRj4_Ce_pMXwBceGFUrhQbsr98Vx44OONobtm40,4267
69
+ basilisk/render/light.py,sha256=hFqODv9iK4GEDZeDyBHxOWwwd4v8Pm089_xoScBMjVY,3879
70
+ basilisk/render/light_handler.py,sha256=Le5InqqjgglSXUu7MwkVVsb7WbNJeRkRKldYDQGr6kg,2161
71
+ basilisk/render/material.py,sha256=JmmwCxSYkPLHw73bH-7SzPo5ewzbU3QPTIvI_2pInXQ,9655
72
+ basilisk/render/material_handler.py,sha256=dbfQs0u7qkEan0e0FsnqPpxbmkSNAQmH2B9jv4vx-bs,4242
73
+ basilisk/render/shader.py,sha256=uFV1gv-MiWRG-nvv2akB0K2SrADWQ54vBYqHeJoy0PY,3913
74
+ basilisk/render/shader_handler.py,sha256=YDl4XGsAUrA_JavmsG2nuoo6k8WyzKNsx20App-RVSk,2511
75
+ basilisk/render/sky.py,sha256=TwLJ_6dYWCOAb06HZocrRdBzlbR6mQ0ojmmJgCC6im4,4910
76
+ basilisk/shaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
+ basilisk/shaders/batch.frag,sha256=658z5GLegHDarroeqUpoiWDCCT2FHMr0ZHnYJ21qMhQ,9339
78
+ basilisk/shaders/batch.vert,sha256=nUZKd5uBTFJm1aOG0auQRxE2ElhcAGf1YmepyzWeG8g,5403
79
+ basilisk/shaders/draw.frag,sha256=XV7dcVm-RhZXs6e6ddJhesR6BAmVWEHZqQgEJQEA77Q,450
80
+ basilisk/shaders/draw.vert,sha256=UQtceYDIUfrluXZSb_Y_L8_-Ky_bjAj9Uyvuu8KkpeE,509
81
+ basilisk/shaders/filter.frag,sha256=m_egR4yiFRmIHGwCCfpcdvGXQi1w1Ago_iABlbnX80c,584
82
+ basilisk/shaders/frame.frag,sha256=rs_AA1u7DL3CxtqpTqvhgQjYYthl_l_Dg7RXpU9_5Ks,160
83
+ basilisk/shaders/frame.vert,sha256=KPB-Q3-Rix9-JxSj5tBHbZOu7QCdFgCzHwiZKEYIbFc,227
84
+ basilisk/shaders/geometry.frag,sha256=Vh57G0r7Jj0uaTQEYuovZSgzOIJyZi-bzGvNsWZ--Oc,157
85
+ basilisk/shaders/geometry.vert,sha256=2yPpezklovRQczpuf2pUhi4mMv3-YaOjDQCbrzdcdpk,1473
86
+ basilisk/shaders/normal.frag,sha256=E6EwJUf76VCT8B_huuLfHRVRF7PkWxG1YGjdWh6sC44,1333
87
+ basilisk/shaders/normal.vert,sha256=4BlcNsIw3fQFsZlfF7VZr6EAV2Y-M-72tXhfaE0uReM,3320
88
+ basilisk/shaders/particle.frag,sha256=Cv8cWQpVVQvhZeWj3NqL0D5nLtSO3EWV0VzOU-ZVL4Y,1816
89
+ basilisk/shaders/particle.vert,sha256=ElXzT7ywiZ0SjrFcUistVDBi4wOobQ7_J5O7XVxrsVs,3027
90
+ basilisk/shaders/sky.frag,sha256=vTmZ1Xsd601_gmeBRfLYodHuBoBDI-M_1IybRt0ZDFk,178
91
+ basilisk/shaders/sky.vert,sha256=v_BSdnMiljSJGPqno-J_apAiom38IrBzbDoxM7pIgwI,345
92
+ basilisk_engine-0.1.1.dist-info/METADATA,sha256=SpvKfqw7cM2tzYG0duJeQZY5pmwPggRdVptnp_2PZIc,1146
93
+ basilisk_engine-0.1.1.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
94
+ basilisk_engine-0.1.1.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
95
+ basilisk_engine-0.1.1.dist-info/RECORD,,
Binary file