basilisk-engine 0.1.28__tar.gz → 0.1.29__tar.gz

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 (163) hide show
  1. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/PKG-INFO +1 -1
  2. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/input_validation.py +9 -1
  3. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/framebuffer.py +26 -6
  4. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/image.py +34 -1
  5. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/material.py +3 -1
  6. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/material_handler.py +2 -0
  7. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/shader.py +17 -1
  8. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk_engine.egg-info/PKG-INFO +1 -1
  9. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk_engine.egg-info/SOURCES.txt +5 -1
  10. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/setup.py +1 -1
  11. basilisk_engine-0.1.29/tests/shaders/image_test.frag +12 -0
  12. basilisk_engine-0.1.29/tests/shaders/image_test.vert +50 -0
  13. basilisk_engine-0.1.29/tests/shaders/multi_render_test.frag +24 -0
  14. basilisk_engine-0.1.29/tests/shaders/multi_render_test.vert +65 -0
  15. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/MANIFEST.in +0 -0
  16. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/README.md +0 -0
  17. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/__init__.py +0 -0
  18. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/audio/__init__.py +0 -0
  19. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/audio/sound.py +0 -0
  20. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/bsk_assets/Roboto-Regular.ttf +0 -0
  21. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/bsk_assets/__init__.py +0 -0
  22. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/bsk_assets/basilisk.png +0 -0
  23. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/bsk_assets/cube.obj +0 -0
  24. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/bsk_assets/skybox.png +0 -0
  25. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/__init__.py +0 -0
  26. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/broad/__init__.py +0 -0
  27. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/broad/broad_aabb.py +0 -0
  28. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/broad/broad_bvh.py +0 -0
  29. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/collider.py +0 -0
  30. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/collider_handler.py +0 -0
  31. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/__init__.py +0 -0
  32. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/contact_manifold.py +0 -0
  33. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/dataclasses.py +0 -0
  34. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/deprecated.py +0 -0
  35. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/epa.py +0 -0
  36. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/gjk.py +0 -0
  37. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/graham_scan.py +0 -0
  38. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/helper.py +0 -0
  39. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/line_intersections.py +0 -0
  40. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/collisions/narrow/sutherland_hodgman.py +0 -0
  41. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/config.py +0 -0
  42. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/draw/__init__.py +0 -0
  43. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/draw/draw.py +0 -0
  44. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/draw/draw_handler.py +0 -0
  45. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/draw/font_renderer.py +0 -0
  46. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/engine.py +0 -0
  47. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/__init__.py +0 -0
  48. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/abstract_bvh.py +0 -0
  49. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/abstract_custom.py +0 -0
  50. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/collisions.py +0 -0
  51. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/math.py +0 -0
  52. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/matrices.py +0 -0
  53. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/meshes.py +0 -0
  54. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/quat.py +0 -0
  55. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/quat_methods.py +0 -0
  56. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/raycast_result.py +0 -0
  57. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/generic/vec3.py +0 -0
  58. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/input_output/IO_handler.py +0 -0
  59. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/input_output/__init__.py +0 -0
  60. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/input_output/clock.py +0 -0
  61. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/input_output/keys.py +0 -0
  62. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/input_output/mouse.py +0 -0
  63. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/input_output/path.py +0 -0
  64. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/__init__.py +0 -0
  65. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/cube.py +0 -0
  66. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/mesh.py +0 -0
  67. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/mesh_from_data.py +0 -0
  68. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/model.py +0 -0
  69. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/narrow_aabb.py +0 -0
  70. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/narrow_bvh.py +0 -0
  71. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/mesh/narrow_primative.py +0 -0
  72. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/nodes/__init__.py +0 -0
  73. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/nodes/helper.py +0 -0
  74. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/nodes/node.py +0 -0
  75. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/nodes/node_handler.py +0 -0
  76. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/particles/__init__.py +0 -0
  77. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/particles/particle_handler.py +0 -0
  78. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/particles/particle_renderer.py +0 -0
  79. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/physics/__init__.py +0 -0
  80. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/physics/impulse.py +0 -0
  81. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/physics/physics_body.py +0 -0
  82. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/physics/physics_engine.py +0 -0
  83. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/__init__.py +0 -0
  84. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/batch.py +0 -0
  85. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/camera.py +0 -0
  86. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/chunk.py +0 -0
  87. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/chunk_handler.py +0 -0
  88. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/frame.py +0 -0
  89. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/image_handler.py +0 -0
  90. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/light.py +0 -0
  91. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/light_handler.py +0 -0
  92. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/post_process.py +0 -0
  93. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/shader_handler.py +0 -0
  94. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/render/sky.py +0 -0
  95. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/scene.py +0 -0
  96. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/__init__.py +0 -0
  97. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/batch.frag +0 -0
  98. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/batch.vert +0 -0
  99. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/crt.frag +0 -0
  100. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/draw.frag +0 -0
  101. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/draw.vert +0 -0
  102. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/filter.frag +0 -0
  103. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/frame.frag +0 -0
  104. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/frame.vert +0 -0
  105. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/geometry.frag +0 -0
  106. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/geometry.vert +0 -0
  107. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/normal.frag +0 -0
  108. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/normal.vert +0 -0
  109. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/particle.frag +0 -0
  110. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/particle.vert +0 -0
  111. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/sky.frag +0 -0
  112. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk/shaders/sky.vert +0 -0
  113. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk_engine.egg-info/dependency_links.txt +0 -0
  114. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk_engine.egg-info/requires.txt +0 -0
  115. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/basilisk_engine.egg-info/top_level.txt +0 -0
  116. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/docs/images/0_boilerplate.png +0 -0
  117. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/images/cloth.png +0 -0
  118. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/images/floor.png +0 -0
  119. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/images/foil.png +0 -0
  120. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/images/mud.png +0 -0
  121. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/setup.cfg +0 -0
  122. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/SkySkybox.png +0 -0
  123. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/box_three.obj +0 -0
  124. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/box_three_lid.obj +0 -0
  125. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/brick.png +0 -0
  126. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/brick_normal.png +0 -0
  127. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/bunny.obj +0 -0
  128. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/closet_001.obj +0 -0
  129. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/cloth_albedo.png +0 -0
  130. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/cloth_normal.png +0 -0
  131. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/cube.obj +0 -0
  132. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/cubemaps_skybox.png +0 -0
  133. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/cylinder.obj +0 -0
  134. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/demo_sphere.obj +0 -0
  135. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/dirt.png +0 -0
  136. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/drawer.obj +0 -0
  137. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/dresser.obj +0 -0
  138. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/floor_albedo.png +0 -0
  139. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/floor_normal.png +0 -0
  140. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/foil_normal.png +0 -0
  141. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/fridge_001.obj +0 -0
  142. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/grass.jpg +0 -0
  143. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/grass_ao.jpg +0 -0
  144. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/grass_block_side.png +0 -0
  145. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/grass_block_top.png +0 -0
  146. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/grass_normal.png +0 -0
  147. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/grass_roughness.jpg +0 -0
  148. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/image.png +0 -0
  149. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/john.obj +0 -0
  150. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/key.obj +0 -0
  151. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/lucy.obj +0 -0
  152. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/monkey.obj +0 -0
  153. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/mud.png +0 -0
  154. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/mud_normal.png +0 -0
  155. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/oak_tree.obj +0 -0
  156. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/picture_frame.obj +0 -0
  157. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/shaders/custom_format.frag +0 -0
  158. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/shaders/custom_format.vert +0 -0
  159. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/skybox.png +0 -0
  160. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/sock.obj +0 -0
  161. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/sphere.obj +0 -0
  162. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/wedge.obj +0 -0
  163. {basilisk_engine-0.1.28 → basilisk_engine-0.1.29}/tests/wheel_eight.obj +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: basilisk-engine
3
- Version: 0.1.28
3
+ Version: 0.1.29
4
4
  Summary: Python 3D Framework
5
5
  Home-page: https://basilisk-website.vercel.app/
6
6
  Author: Name
@@ -3,6 +3,14 @@ import glm
3
3
  from ..render.image import Image
4
4
 
5
5
 
6
+ def validate_int(module: str, name: str, value: int | float | glm.int32) -> float:
7
+ if isinstance(value, int) or isinstance(value, float):
8
+ return int(round(value))
9
+ elif isinstance(value, glm.int32):
10
+ return int(value.value)
11
+ else:
12
+ raise TypeError(f"{module}: Invalid {name} value type {type(value)}. Expected float.")
13
+
6
14
  def validate_float(module: str, name: str, value: float | int | glm.float32) -> float:
7
15
  if isinstance(value, float) or isinstance(value, int):
8
16
  return float(value)
@@ -10,7 +18,7 @@ def validate_float(module: str, name: str, value: float | int | glm.float32) ->
10
18
  return float(value.value)
11
19
  else:
12
20
  raise TypeError(f"{module}: Invalid {name} value type {type(value)}. Expected float.")
13
-
21
+
14
22
  def validate_glm_vec3(module: str, name: str, value: tuple | list | glm.vec3 | np.ndarray) -> glm.vec3:
15
23
  if isinstance(value, tuple) or isinstance(value, list) or isinstance(value, np.ndarray):
16
24
  if len(value) != 3: raise ValueError(f"{module}: Invalid number of values for {name}. Expected 3 values, got {len(value)} values")
@@ -2,6 +2,7 @@ import numpy as np
2
2
  import moderngl as mgl
3
3
  from PIL import Image
4
4
  from ..render.shader import Shader
5
+ from ..generic.input_validation import validate_int
5
6
 
6
7
 
7
8
  class Framebuffer:
@@ -36,7 +37,7 @@ class Framebuffer:
36
37
  self._size = size
37
38
  self.scale = scale
38
39
  self.texture_filter = (mgl.LINEAR, mgl.LINEAR) if linear_filter else (mgl.NEAREST, mgl.NEAREST)
39
- self.n_attachments = n_color_attachments
40
+ self.n_attachments = n_color_attachments
40
41
 
41
42
  self.load_pipeline()
42
43
  self.generate_fbo()
@@ -59,6 +60,10 @@ class Framebuffer:
59
60
  # Create the internal fbo
60
61
  self.fbo = self.ctx.framebuffer(self._color_attachments, self._depth_attachment)
61
62
 
63
+ # Set the show attachment to default
64
+ self._show = -1
65
+ self.show = 0
66
+
62
67
  def resize(self, new_size: tuple[int]=None) -> None:
63
68
  """
64
69
  Update set size framebuffers with the given size.
@@ -86,13 +91,18 @@ class Framebuffer:
86
91
  self.vbo = self.ctx.buffer(np.array([[-1, -1, 0, 0, 0], [1, -1, 0, 1, 0], [1, 1, 0, 1, 1], [-1, 1, 0, 0, 1], [-1, -1, 0, 0, 0], [1, 1, 0, 1, 1]], dtype='f4'))
87
92
  self.vao = self.ctx.vertex_array(self.shader.program, [(self.vbo, '3f 2f', 'in_position', 'in_uv')], skip_errors=True)
88
93
 
89
- def render(self, render_target=None) -> None:
94
+ def render(self, render_target=None, show: int=None) -> None:
95
+ """
96
+ Render the fbo to the screen
97
+ If the fbo has multiple attachments, show will specifiy which is shown
98
+ Depth is considered the last show element
99
+ """
90
100
 
91
- target = render_target if render_target else self.engine.frame
101
+ if not isinstance(show, type(None)): self.show = show
92
102
 
103
+ target = render_target if render_target else self.engine.frame
93
104
  target.use()
94
- self.shader.program['screenTexture'] = 0
95
- self.texture.use(location=0)
105
+
96
106
  self.vao.render()
97
107
 
98
108
  def use(self) -> None:
@@ -143,13 +153,23 @@ class Framebuffer:
143
153
  def data(self) -> bytes:
144
154
  """Reads the data from the fbo"""
145
155
  return self.fbo.read()
146
-
156
+ @property
157
+ def show(self) -> int:
158
+ return self._show
147
159
 
148
160
  @size.setter
149
161
  def size(self, value: tuple[int]=None) -> tuple[int]:
150
162
  self.resize(value)
151
163
  return self.size
152
164
 
165
+ @show.setter
166
+ def show(self, value: int) -> None:
167
+ value = validate_int("Framebuffer", "show", value)
168
+ if value == self._show: return
169
+ self._show = value
170
+ self.shader.program['screenTexture'] = value+1
171
+ self.color_attachments[value].use(location=value+1)
172
+
153
173
  def __repr__(self) -> str:
154
174
  return f'<bsk.Framebuffer | size: {self.size}>'
155
175
 
@@ -19,6 +19,8 @@ class Image():
19
19
  """Array of the texture data"""
20
20
  size: int
21
21
  """The width and height in pixels of the image"""
22
+ texture: mgl.Texture | None=None
23
+ """Texture of the image. Only created and retrived if needed by other module"""
22
24
 
23
25
  def __init__(self, path: str | os.PathLike | pg.Surface | mgl.Texture) -> None:
24
26
  """
@@ -81,8 +83,39 @@ class Image():
81
83
  """
82
84
  ...
83
85
 
86
+ def build_texture(self, ctx: mgl.Context) -> mgl.Texture:
87
+ """
88
+ Builds a texture from the image data
89
+ """
90
+
91
+ # Release existing memory
92
+ if self.texture: self.texture.release()
93
+
94
+ # Make the texture from image data
95
+ self.texture = ctx.texture((self.size, self.size), components=4, data=self.data)
96
+ # Texture formatting
97
+ self.texture.build_mipmaps()
98
+ self.texture.filter = (mgl.LINEAR_MIPMAP_LINEAR, mgl.LINEAR)
99
+ self.texture.anisotropy = 32.0
100
+
101
+ return self.texture
102
+
103
+ def use(self, slot: int) -> None:
104
+ """
105
+ Use the image at the given slot
106
+ """
107
+
108
+ if not self.texture:
109
+ raise LookupError("bsk.Image: cannot use an image without a texture. Use texture.build_texture() before texture.use()")
110
+
111
+ # Bind to the given slot
112
+ self.texture.use(location=slot)
113
+
84
114
  def __repr__(self) -> str:
85
115
  """
86
116
  Returns a string representation of the object
87
117
  """
88
- return f'<Basilisk Image | {self.name}, ({self.size}x{self.size}), {sys.getsizeof(self.data) / 1024 / 1024:.2} mb>'
118
+ return f'<Basilisk Image | {self.name}, ({self.size}x{self.size}), {sys.getsizeof(self.data) / 1024 / 1024:.2} mb>'
119
+
120
+ def __del__(self) -> None:
121
+ if self.texture: self.texture.release()
@@ -152,7 +152,9 @@ class Material():
152
152
  @texture.setter
153
153
  def texture(self, value: Image | None):
154
154
  self._texture = validate_image("Material", "texture", value)
155
- if self.material_handler: self.material_handler.write(regenerate=True)
155
+ if not self.material_handler: return
156
+ self.material_handler.image_handler.add(value)
157
+ self.material_handler.write(regenerate=True)
156
158
 
157
159
  @normal.setter
158
160
  def normal(self, value: Image | None):
@@ -13,6 +13,8 @@ class MaterialHandler():
13
13
  """List containing all the materials in the engine"""
14
14
  data_texture: mgl.Texture
15
15
  """ModernGL texture containing all the material data for materials in the engine"""
16
+ image_handler: ImageHandler=None
17
+ """Handler for all images in the game"""
16
18
 
17
19
  def __init__(self, engine) -> None:
18
20
  """
@@ -1,5 +1,5 @@
1
1
  import moderngl as mgl
2
- import random
2
+ from .image import Image
3
3
 
4
4
  attribute_mappings = {
5
5
  'in_position' : [0, 1, 2],
@@ -48,6 +48,7 @@ class Shader:
48
48
  self.attribute_indices = []
49
49
  self.fmt = ''
50
50
  self.attributes = []
51
+ self.bindings = 1
51
52
 
52
53
  # Default vertex and fragment shaders
53
54
  if vert == None: vert = self.engine.root + '/shaders/batch.vert'
@@ -112,6 +113,21 @@ class Shader:
112
113
 
113
114
  self.program[name].write(value)
114
115
 
116
+ def bind(self, sampler: mgl.Texture | mgl.TextureArray | mgl.TextureCube | Image, name: str, slot: int=None) -> None:
117
+ """
118
+ Binds the given sampler to the next availible slot
119
+ """
120
+
121
+ # Use the next slot if no slot is given
122
+ if not slot: slot = self.bindings; self.bindings+=1
123
+
124
+ if isinstance(sampler, Image,): sampler = sampler.build_texture(self.ctx)
125
+
126
+ # Use the sampler
127
+ self.program[name] = slot
128
+ sampler.use(location=slot)
129
+
130
+
115
131
  def __del__(self) -> int:
116
132
  if self.program: self.program.release()
117
133
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: basilisk-engine
3
- Version: 0.1.28
3
+ Version: 0.1.29
4
4
  Summary: Python 3D Framework
5
5
  Home-page: https://basilisk-website.vercel.app/
6
6
  Author: Name
@@ -154,4 +154,8 @@ tests/sphere.obj
154
154
  tests/wedge.obj
155
155
  tests/wheel_eight.obj
156
156
  tests/shaders/custom_format.frag
157
- tests/shaders/custom_format.vert
157
+ tests/shaders/custom_format.vert
158
+ tests/shaders/image_test.frag
159
+ tests/shaders/image_test.vert
160
+ tests/shaders/multi_render_test.frag
161
+ tests/shaders/multi_render_test.vert
@@ -7,7 +7,7 @@ with open(path.join(working_directory, 'README.md'), encoding='utf-8') as f:
7
7
 
8
8
  setup(
9
9
  name = 'basilisk-engine', # Name of folder containing scripts and __init__
10
- version = '0.1.28',
10
+ version = '0.1.29',
11
11
  url = 'https://basilisk-website.vercel.app/',
12
12
  author = 'Name',
13
13
  author_email = 'basiliskengine@gmail.com',
@@ -0,0 +1,12 @@
1
+ #version 330 core
2
+
3
+ out vec4 fragColor;
4
+
5
+ in vec2 uv;
6
+
7
+ uniform sampler2D image;
8
+
9
+ void main()
10
+ {
11
+ fragColor = vec4(texture(image, uv).rgb, 1.0);
12
+ }
@@ -0,0 +1,50 @@
1
+ #version 330 core
2
+
3
+ layout (location = 0) in vec3 in_position;
4
+ layout (location = 1) in vec2 in_uv;
5
+
6
+ layout (location = 2) in vec3 obj_position;
7
+ layout (location = 3) in vec4 obj_rotation;
8
+ layout (location = 4) in vec3 obj_scale;
9
+ layout (location = 5) in float obj_material;
10
+
11
+
12
+ out vec2 uv;
13
+
14
+ // Uniforms
15
+ uniform mat4 projectionMatrix;
16
+ uniform mat4 viewMatrix;
17
+
18
+ // Function to get the model matrix from node position, rotation, and scale
19
+ mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
20
+ mat4 translation = mat4(
21
+ 1 , 0 , 0 , 0,
22
+ 0 , 1 , 0 , 0,
23
+ 0 , 0 , 1 , 0,
24
+ pos.x, pos.y, pos.z, 1
25
+ );
26
+ mat4 rotation = mat4(
27
+ 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,
28
+ 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,
29
+ 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,
30
+ 0, 0, 0, 1
31
+ );
32
+ mat4 scale = mat4(
33
+ scl.x, 0 , 0 , 0,
34
+ 0 , scl.y, 0 , 0,
35
+ 0 , 0 , scl.z, 0,
36
+ 0 , 0 , 0 , 1
37
+ );
38
+ return translation * rotation * scale;
39
+ }
40
+
41
+ void main() {
42
+ // Set the model matrix
43
+ mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
44
+
45
+ // Pass the uv
46
+ uv = in_uv;
47
+
48
+ // Set the fragment position
49
+ gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
50
+ }
@@ -0,0 +1,24 @@
1
+ #version 330 core
2
+
3
+ layout (location = 0) out vec4 gSolid;
4
+ layout (location = 1) out vec4 gPosition;
5
+ layout (location = 2) out vec4 gUV;
6
+ layout (location = 3) out vec4 gNormal;
7
+ layout (location = 4) out vec4 gTangent;
8
+ layout (location = 5) out vec4 gBitangent;
9
+
10
+
11
+ in vec2 uv;
12
+ in vec3 position;
13
+ in mat3 TBN;
14
+
15
+
16
+ void main()
17
+ {
18
+ gSolid = vec4(1.0);
19
+ gPosition = vec4(position, 1.0);
20
+ gUV = vec4(uv, 0.0, 1.0);
21
+ gNormal = vec4(TBN[2], 1.0);
22
+ gTangent = vec4(TBN[0], 1.0);
23
+ gBitangent = vec4(TBN[1], 1.0);
24
+ }
@@ -0,0 +1,65 @@
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
+
13
+ // Variables passed on to the fragment shader
14
+ out vec2 uv;
15
+ out vec3 position;
16
+ out mat3 TBN;
17
+
18
+
19
+ // Uniforms
20
+ uniform mat4 projectionMatrix;
21
+ uniform mat4 viewMatrix;
22
+
23
+ // Function to get the model matrix from node position, rotation, and scale
24
+ mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
25
+ mat4 translation = mat4(
26
+ 1 , 0 , 0 , 0,
27
+ 0 , 1 , 0 , 0,
28
+ 0 , 0 , 1 , 0,
29
+ pos.x, pos.y, pos.z, 1
30
+ );
31
+ mat4 rotation = mat4(
32
+ 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,
33
+ 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,
34
+ 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,
35
+ 0, 0, 0, 1
36
+ );
37
+ mat4 scale = mat4(
38
+ scl.x, 0 , 0 , 0,
39
+ 0 , scl.y, 0 , 0,
40
+ 0 , 0 , scl.z, 0,
41
+ 0 , 0 , 0 , 1
42
+ );
43
+ return translation * rotation * scale;
44
+ }
45
+
46
+ // Function to get the TBN matrix for normal mapping
47
+ mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
48
+ vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
49
+ vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
50
+ vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
51
+ return mat3(T, B, N);
52
+ }
53
+
54
+ void main() {
55
+ // Set the model matrix
56
+ mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
57
+
58
+ // Set out variables
59
+ position = (modelMatrix * vec4(in_position, 1.0)).xyz;
60
+ TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
61
+ uv = in_uv;
62
+
63
+ // Set the fragment position
64
+ gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
65
+ }