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,116 +1,116 @@
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 vec3 position;
17
- out mat3 TBN;
18
-
19
- // Material struct sent to fragment shader
20
- struct Material {
21
- vec3 color;
22
- float roughness;
23
- float subsurface;
24
- float sheen;
25
- float sheenTint;
26
- float anisotropic;
27
- float specular;
28
- float metallicness;
29
- float specularTint;
30
- float clearcoat;
31
- float clearcoatGloss;
32
-
33
- int hasAlbedoMap;
34
- vec2 albedoMap;
35
- int hasNormalMap;
36
- vec2 normalMap;
37
- int hasRoughnessMap;
38
- vec2 roughnessMap;
39
- int hasAoMap;
40
- vec2 aoMap;
41
- };
42
- flat out Material mtl;
43
-
44
- // Uniforms
45
- uniform mat4 projectionMatrix;
46
- uniform mat4 viewMatrix;
47
- uniform sampler2D materialsTexture;
48
-
49
- // Function to get the model matrix from node position, rotation, and scale
50
- mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
51
- mat4 translation = mat4(
52
- 1 , 0 , 0 , 0,
53
- 0 , 1 , 0 , 0,
54
- 0 , 0 , 1 , 0,
55
- pos.x, pos.y, pos.z, 1
56
- );
57
- mat4 rotation = mat4(
58
- 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,
59
- 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,
60
- 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,
61
- 0, 0, 0, 1
62
- );
63
- mat4 scale = mat4(
64
- scl.x, 0 , 0 , 0,
65
- 0 , scl.y, 0 , 0,
66
- 0 , 0 , scl.z, 0,
67
- 0 , 0 , 0 , 1
68
- );
69
- return translation * rotation * scale;
70
- }
71
-
72
- // Function to get the TBN matrix for normal mapping
73
- mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
74
- vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
75
- vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
76
- vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
77
- return mat3(T, B, N);
78
- }
79
-
80
- void main() {
81
- // Set the model matrix
82
- mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
83
-
84
- // Set out variables
85
- position = (modelMatrix * vec4(in_position, 1.0)).xyz;
86
- TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
87
- uv = in_uv;
88
-
89
- // Get the material
90
- int mtl_size = 25;
91
- int materialID = int(obj_material);
92
-
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);
94
- mtl.roughness = texelFetch(materialsTexture, ivec2(0, 3 + materialID * mtl_size), 0).r;
95
- mtl.subsurface = texelFetch(materialsTexture, ivec2(0, 4 + materialID * mtl_size), 0).r;
96
- mtl.sheen = texelFetch(materialsTexture, ivec2(0, 5 + materialID * mtl_size), 0).r;
97
- mtl.sheenTint = texelFetch(materialsTexture, ivec2(0, 6 + materialID * mtl_size), 0).r;
98
- mtl.anisotropic = texelFetch(materialsTexture, ivec2(0, 7 + materialID * mtl_size), 0).r;
99
- mtl.specular = texelFetch(materialsTexture, ivec2(0, 8 + materialID * mtl_size), 0).r;
100
- mtl.metallicness = texelFetch(materialsTexture, ivec2(0, 9 + materialID * mtl_size), 0).r;
101
- mtl.specularTint = texelFetch(materialsTexture, ivec2(0, 10 + materialID * mtl_size), 0).r;
102
- mtl.clearcoat = texelFetch(materialsTexture, ivec2(0, 11 + materialID * mtl_size), 0).r;
103
- mtl.clearcoatGloss = texelFetch(materialsTexture, ivec2(0, 12 + materialID * mtl_size), 0).r;
104
-
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);
113
-
114
- // Set the fragment position
115
- 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 vec3 position;
17
+ out mat3 TBN;
18
+
19
+ // Material struct sent to fragment shader
20
+ struct Material {
21
+ vec3 color;
22
+ float roughness;
23
+ float subsurface;
24
+ float sheen;
25
+ float sheenTint;
26
+ float anisotropic;
27
+ float specular;
28
+ float metallicness;
29
+ float specularTint;
30
+ float clearcoat;
31
+ float clearcoatGloss;
32
+
33
+ int hasAlbedoMap;
34
+ vec2 albedoMap;
35
+ int hasNormalMap;
36
+ vec2 normalMap;
37
+ int hasRoughnessMap;
38
+ vec2 roughnessMap;
39
+ int hasAoMap;
40
+ vec2 aoMap;
41
+ };
42
+ flat out Material mtl;
43
+
44
+ // Uniforms
45
+ uniform mat4 projectionMatrix;
46
+ uniform mat4 viewMatrix;
47
+ uniform sampler2D materialsTexture;
48
+
49
+ // Function to get the model matrix from node position, rotation, and scale
50
+ mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
51
+ mat4 translation = mat4(
52
+ 1 , 0 , 0 , 0,
53
+ 0 , 1 , 0 , 0,
54
+ 0 , 0 , 1 , 0,
55
+ pos.x, pos.y, pos.z, 1
56
+ );
57
+ mat4 rotation = mat4(
58
+ 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,
59
+ 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,
60
+ 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,
61
+ 0, 0, 0, 1
62
+ );
63
+ mat4 scale = mat4(
64
+ scl.x, 0 , 0 , 0,
65
+ 0 , scl.y, 0 , 0,
66
+ 0 , 0 , scl.z, 0,
67
+ 0 , 0 , 0 , 1
68
+ );
69
+ return translation * rotation * scale;
70
+ }
71
+
72
+ // Function to get the TBN matrix for normal mapping
73
+ mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
74
+ vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
75
+ vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
76
+ vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
77
+ return mat3(T, B, N);
78
+ }
79
+
80
+ void main() {
81
+ // Set the model matrix
82
+ mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
83
+
84
+ // Set out variables
85
+ position = (modelMatrix * vec4(in_position, 1.0)).xyz;
86
+ TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
87
+ uv = in_uv;
88
+
89
+ // Get the material
90
+ int mtl_size = 25;
91
+ int materialID = int(obj_material);
92
+
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);
94
+ mtl.roughness = texelFetch(materialsTexture, ivec2(0, 3 + materialID * mtl_size), 0).r;
95
+ mtl.subsurface = texelFetch(materialsTexture, ivec2(0, 4 + materialID * mtl_size), 0).r;
96
+ mtl.sheen = texelFetch(materialsTexture, ivec2(0, 5 + materialID * mtl_size), 0).r;
97
+ mtl.sheenTint = texelFetch(materialsTexture, ivec2(0, 6 + materialID * mtl_size), 0).r;
98
+ mtl.anisotropic = texelFetch(materialsTexture, ivec2(0, 7 + materialID * mtl_size), 0).r;
99
+ mtl.specular = texelFetch(materialsTexture, ivec2(0, 8 + materialID * mtl_size), 0).r;
100
+ mtl.metallicness = texelFetch(materialsTexture, ivec2(0, 9 + materialID * mtl_size), 0).r;
101
+ mtl.specularTint = texelFetch(materialsTexture, ivec2(0, 10 + materialID * mtl_size), 0).r;
102
+ mtl.clearcoat = texelFetch(materialsTexture, ivec2(0, 11 + materialID * mtl_size), 0).r;
103
+ mtl.clearcoatGloss = texelFetch(materialsTexture, ivec2(0, 12 + materialID * mtl_size), 0).r;
104
+
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);
113
+
114
+ // Set the fragment position
115
+ gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
116
116
  }
@@ -1,22 +1,22 @@
1
- #version 330 core
2
-
3
- layout (location = 0) out vec4 fragColor;
4
-
5
- in vec4 color;
6
- in vec2 imageIndex;
7
- in vec2 uv;
8
- flat in int usesImage;
9
-
10
- struct textArray {
11
- sampler2DArray array;
12
- };
13
- uniform textArray textureArrays[5];
14
-
15
- void main() {
16
- if (bool(usesImage)) {
17
- fragColor = texture(textureArrays[int(round(imageIndex.x))].array, vec3(uv, round(imageIndex.y)));
18
- }
19
- else {
20
- fragColor = color;
21
- }
1
+ #version 330 core
2
+
3
+ layout (location = 0) out vec4 fragColor;
4
+
5
+ in vec4 color;
6
+ in vec2 imageIndex;
7
+ in vec2 uv;
8
+ flat in int usesImage;
9
+
10
+ struct textArray {
11
+ sampler2DArray array;
12
+ };
13
+ uniform textArray textureArrays[5];
14
+
15
+ void main() {
16
+ if (bool(usesImage)) {
17
+ fragColor = texture(textureArrays[int(round(imageIndex.x))].array, vec3(uv, round(imageIndex.y)));
18
+ }
19
+ else {
20
+ fragColor = color;
21
+ }
22
22
  }
@@ -1,22 +1,22 @@
1
- #version 330 core
2
-
3
- layout (location = 0) in vec2 in_position;
4
- layout (location = 1) in vec4 in_color;
5
- layout (location = 2) in int in_uses_image;
6
-
7
- out vec4 color;
8
- out vec2 imageIndex;
9
- out vec2 uv;
10
- flat out int usesImage;
11
-
12
- void main() {
13
- usesImage = in_uses_image;
14
- if (bool(in_uses_image)) {
15
- imageIndex = in_color.xy;
16
- uv = in_color.zw;
17
- }
18
- else{
19
- color = in_color;
20
- }
21
- gl_Position = vec4(in_position.x, -in_position.y, 0.0, 1.0);
1
+ #version 330 core
2
+
3
+ layout (location = 0) in vec2 in_position;
4
+ layout (location = 1) in vec4 in_color;
5
+ layout (location = 2) in int in_uses_image;
6
+
7
+ out vec4 color;
8
+ out vec2 imageIndex;
9
+ out vec2 uv;
10
+ flat out int usesImage;
11
+
12
+ void main() {
13
+ usesImage = in_uses_image;
14
+ if (bool(in_uses_image)) {
15
+ imageIndex = in_color.xy;
16
+ uv = in_color.zw;
17
+ }
18
+ else{
19
+ color = in_color;
20
+ }
21
+ gl_Position = vec4(in_position.x, -in_position.y, 0.0, 1.0);
22
22
  }
@@ -1,23 +1,23 @@
1
- #version 330 core
2
-
3
- out vec4 fragColor;
4
-
5
- in vec2 uv;
6
-
7
- uniform sampler2D screenTexture;
8
-
9
-
10
- void main()
11
- {
12
- vec2 direction = normalize(vec2(1.0, 1.0));
13
- float magnitude = 0.6;
14
- float redOffset = 0.009 * magnitude;
15
- float greenOffset = 0.006 * magnitude;
16
- float blueOffset = -0.006 * magnitude;
17
-
18
- float r = texture(screenTexture, uv + direction * redOffset).r;
19
- float g = texture(screenTexture, uv + direction * greenOffset).g;
20
- float b = texture(screenTexture, uv + direction * blueOffset).b;
21
-
22
- fragColor = vec4(r, g, b, 1.0);
1
+ #version 330 core
2
+
3
+ out vec4 fragColor;
4
+
5
+ in vec2 uv;
6
+
7
+ uniform sampler2D screenTexture;
8
+
9
+
10
+ void main()
11
+ {
12
+ vec2 direction = normalize(vec2(1.0, 1.0));
13
+ float magnitude = 0.6;
14
+ float redOffset = 0.009 * magnitude;
15
+ float greenOffset = 0.006 * magnitude;
16
+ float blueOffset = -0.006 * magnitude;
17
+
18
+ float r = texture(screenTexture, uv + direction * redOffset).r;
19
+ float g = texture(screenTexture, uv + direction * greenOffset).g;
20
+ float b = texture(screenTexture, uv + direction * blueOffset).b;
21
+
22
+ fragColor = vec4(r, g, b, 1.0);
23
23
  }
@@ -1,13 +1,13 @@
1
- #version 330 core
2
-
3
- out vec4 fragColor;
4
-
5
- in vec2 uv;
6
-
7
- uniform sampler2D screenTexture;
8
-
9
-
10
- void main()
11
- {
12
- fragColor = texture(screenTexture, uv);
1
+ #version 330 core
2
+
3
+ out vec4 fragColor;
4
+
5
+ in vec2 uv;
6
+
7
+ uniform sampler2D screenTexture;
8
+
9
+
10
+ void main()
11
+ {
12
+ fragColor = texture(screenTexture, uv);
13
13
  }
@@ -1,14 +1,14 @@
1
- #version 330 core
2
-
3
-
4
- layout (location = 0) in vec3 in_position;
5
- layout (location = 1) in vec2 in_uv;
6
-
7
- out vec2 uv;
8
-
9
-
10
- void main()
11
- {
12
- gl_Position = vec4(in_position.x, in_position.y, 0.0, 1.0);
13
- uv = in_uv;
1
+ #version 330 core
2
+
3
+
4
+ layout (location = 0) in vec3 in_position;
5
+ layout (location = 1) in vec2 in_uv;
6
+
7
+ out vec2 uv;
8
+
9
+
10
+ void main()
11
+ {
12
+ gl_Position = vec4(in_position.x, in_position.y, 0.0, 1.0);
13
+ uv = in_uv;
14
14
  }
@@ -1,9 +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);
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
9
  }
@@ -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
  }
@@ -1,60 +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);
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
60
  }