fake-bpy-module 20240417__py3-none-any.whl → 20240419__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 fake-bpy-module might be problematic. Click here for more details.
- _bpy_internal/__init__.pyi +4 -0
- _bpy_internal/freedesktop/__init__.pyi +88 -0
- _bpy_internal/freedesktop/py.typed +0 -0
- _bpy_internal/py.typed +0 -0
- aud/__init__.pyi +121 -48
- bgl/__init__.pyi +2443 -1265
- bl_math/__init__.pyi +19 -3
- bl_operators/geometry_nodes/__init__.pyi +13 -0
- bl_ui/properties_data_light/__init__.pyi +337 -0
- blf/__init__.pyi +63 -13
- bmesh/__init__.pyi +13 -0
- bmesh/geometry/__init__.pyi +5 -0
- bmesh/ops/__init__.pyi +157 -68
- bmesh/types/__init__.pyi +109 -62
- bmesh/utils/__init__.pyi +11 -2
- bpy/__init__.pyi +7 -0
- bpy/app/__init__.pyi +13 -0
- bpy/app/handlers/__init__.pyi +41 -0
- bpy/app/icons/__init__.pyi +4 -2
- bpy/app/timers/__init__.pyi +38 -2
- bpy/app/translations/__init__.pyi +58 -0
- bpy/msgbus/__init__.pyi +46 -0
- bpy/ops/__init__.pyi +151 -0
- bpy/ops/action/__init__.pyi +76 -76
- bpy/ops/anim/__init__.pyi +104 -104
- bpy/ops/armature/__init__.pyi +96 -96
- bpy/ops/asset/__init__.pyi +32 -32
- bpy/ops/boid/__init__.pyi +16 -16
- bpy/ops/brush/__init__.pyi +18 -18
- bpy/ops/buttons/__init__.pyi +12 -12
- bpy/ops/cachefile/__init__.pyi +10 -10
- bpy/ops/camera/__init__.pyi +4 -4
- bpy/ops/clip/__init__.pyi +184 -184
- bpy/ops/cloth/__init__.pyi +2 -2
- bpy/ops/collection/__init__.pyi +18 -18
- bpy/ops/console/__init__.pyi +42 -42
- bpy/ops/constraint/__init__.pyi +36 -36
- bpy/ops/curve/__init__.pyi +102 -102
- bpy/ops/curves/__init__.pyi +54 -54
- bpy/ops/cycles/__init__.pyi +6 -6
- bpy/ops/dpaint/__init__.pyi +10 -10
- bpy/ops/ed/__init__.pyi +24 -24
- bpy/ops/export_anim/__init__.pyi +2 -2
- bpy/ops/export_mesh/__init__.pyi +2 -2
- bpy/ops/export_scene/__init__.pyi +7 -7
- bpy/ops/file/__init__.pyi +80 -80
- bpy/ops/fluid/__init__.pyi +28 -28
- bpy/ops/font/__init__.pyi +46 -46
- bpy/ops/geometry/__init__.pyi +20 -20
- bpy/ops/gizmogroup/__init__.pyi +4 -4
- bpy/ops/gpencil/__init__.pyi +300 -300
- bpy/ops/graph/__init__.pyi +130 -130
- bpy/ops/grease_pencil/__init__.pyi +112 -112
- bpy/ops/image/__init__.pyi +92 -92
- bpy/ops/import_anim/__init__.pyi +2 -2
- bpy/ops/import_curve/__init__.pyi +2 -2
- bpy/ops/import_mesh/__init__.pyi +2 -2
- bpy/ops/import_scene/__init__.pyi +6 -6
- bpy/ops/info/__init__.pyi +14 -14
- bpy/ops/lattice/__init__.pyi +16 -16
- bpy/ops/marker/__init__.pyi +22 -22
- bpy/ops/mask/__init__.pyi +78 -78
- bpy/ops/material/__init__.pyi +6 -6
- bpy/ops/mball/__init__.pyi +16 -16
- bpy/ops/mesh/__init__.pyi +326 -326
- bpy/ops/nla/__init__.pyi +80 -80
- bpy/ops/node/__init__.pyi +202 -202
- bpy/ops/object/__init__.pyi +509 -500
- bpy/ops/outliner/__init__.pyi +138 -138
- bpy/ops/paint/__init__.pyi +104 -104
- bpy/ops/paintcurve/__init__.pyi +16 -16
- bpy/ops/palette/__init__.pyi +14 -14
- bpy/ops/particle/__init__.pyi +72 -72
- bpy/ops/pose/__init__.pyi +78 -78
- bpy/ops/poselib/__init__.pyi +18 -18
- bpy/ops/preferences/__init__.pyi +76 -76
- bpy/ops/ptcache/__init__.pyi +14 -14
- bpy/ops/render/__init__.pyi +24 -24
- bpy/ops/rigidbody/__init__.pyi +26 -26
- bpy/ops/scene/__init__.pyi +78 -78
- bpy/ops/screen/__init__.pyi +78 -78
- bpy/ops/script/__init__.pyi +6 -6
- bpy/ops/sculpt/__init__.pyi +62 -62
- bpy/ops/sculpt_curves/__init__.pyi +8 -8
- bpy/ops/sequencer/__init__.pyi +170 -170
- bpy/ops/sound/__init__.pyi +14 -14
- bpy/ops/spreadsheet/__init__.pyi +8 -8
- bpy/ops/surface/__init__.pyi +12 -12
- bpy/ops/text/__init__.pyi +86 -86
- bpy/ops/text_editor/__init__.pyi +2 -2
- bpy/ops/texture/__init__.pyi +8 -8
- bpy/ops/transform/__init__.pyi +54 -54
- bpy/ops/ui/__init__.pyi +64 -64
- bpy/ops/uilist/__init__.pyi +6 -6
- bpy/ops/uv/__init__.pyi +98 -98
- bpy/ops/view2d/__init__.pyi +28 -28
- bpy/ops/view3d/__init__.pyi +134 -134
- bpy/ops/wm/__init__.pyi +224 -224
- bpy/ops/workspace/__init__.pyi +14 -14
- bpy/ops/world/__init__.pyi +2 -2
- bpy/path/__init__.pyi +6 -0
- bpy/props/__init__.pyi +141 -29
- bpy/types/__init__.pyi +101517 -5027
- bpy/utils/__init__.pyi +18 -3
- bpy/utils/previews/__init__.pyi +15 -0
- bpy/utils/units/__init__.pyi +11 -3
- bpy_extras/__init__.pyi +19 -0
- bpy_extras/asset_utils/__init__.pyi +5 -0
- {fake_bpy_module-20240417.dist-info → fake_bpy_module-20240419.dist-info}/METADATA +1 -1
- {fake_bpy_module-20240417.dist-info → fake_bpy_module-20240419.dist-info}/RECORD +139 -135
- {fake_bpy_module-20240417.dist-info → fake_bpy_module-20240419.dist-info}/top_level.txt +1 -0
- freestyle/__init__.pyi +18 -0
- freestyle/chainingiterators/__init__.pyi +20 -5
- freestyle/functions/__init__.pyi +151 -155
- freestyle/predicates/__init__.pyi +53 -46
- freestyle/shaders/__init__.pyi +91 -32
- freestyle/types/__init__.pyi +362 -120
- freestyle/utils/ContextFunctions/__init__.pyi +32 -7
- freestyle/utils/__init__.pyi +13 -1
- gpu/__init__.pyi +225 -0
- gpu/capabilities/__init__.pyi +37 -15
- gpu/matrix/__init__.pyi +7 -1
- gpu/platform/__init__.pyi +5 -0
- gpu/select/__init__.pyi +5 -0
- gpu/shader/__init__.pyi +77 -0
- gpu/state/__init__.pyi +15 -4
- gpu/texture/__init__.pyi +5 -0
- gpu/types/__init__.pyi +91 -33
- gpu_extras/__init__.pyi +15 -0
- gpu_extras/presets/__init__.pyi +16 -4
- imbuf/__init__.pyi +13 -0
- imbuf/types/__init__.pyi +20 -5
- mathutils/__init__.pyi +349 -227
- mathutils/bvhtree/__init__.pyi +21 -8
- mathutils/geometry/__init__.pyi +23 -9
- mathutils/interpolate/__init__.pyi +5 -0
- mathutils/kdtree/__init__.pyi +19 -5
- mathutils/noise/__init__.pyi +87 -41
- {fake_bpy_module-20240417.dist-info → fake_bpy_module-20240419.dist-info}/WHEEL +0 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The Blender Freestyle.ContextFunctions submodule
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
1
6
|
import typing
|
|
2
7
|
import freestyle.types
|
|
3
8
|
|
|
@@ -12,18 +17,20 @@ def get_border() -> typing.Tuple:
|
|
|
12
17
|
|
|
13
18
|
...
|
|
14
19
|
|
|
15
|
-
def get_canvas_height():
|
|
20
|
+
def get_canvas_height() -> int:
|
|
16
21
|
"""Returns the canvas height.
|
|
17
22
|
|
|
18
23
|
:return: The canvas height.
|
|
24
|
+
:rtype: int
|
|
19
25
|
"""
|
|
20
26
|
|
|
21
27
|
...
|
|
22
28
|
|
|
23
|
-
def get_canvas_width():
|
|
29
|
+
def get_canvas_width() -> int:
|
|
24
30
|
"""Returns the canvas width.
|
|
25
31
|
|
|
26
32
|
:return: The canvas width.
|
|
33
|
+
:rtype: int
|
|
27
34
|
"""
|
|
28
35
|
|
|
29
36
|
...
|
|
@@ -37,15 +44,16 @@ def get_selected_fedge() -> freestyle.types.FEdge:
|
|
|
37
44
|
|
|
38
45
|
...
|
|
39
46
|
|
|
40
|
-
def get_time_stamp():
|
|
47
|
+
def get_time_stamp() -> int:
|
|
41
48
|
"""Returns the system time stamp.
|
|
42
49
|
|
|
43
50
|
:return: The system time stamp.
|
|
51
|
+
:rtype: int
|
|
44
52
|
"""
|
|
45
53
|
|
|
46
54
|
...
|
|
47
55
|
|
|
48
|
-
def load_map(file_name: str, map_name: str, num_levels=4, sigma=1.0):
|
|
56
|
+
def load_map(file_name: str, map_name: str, num_levels: int = 4, sigma: float = 1.0):
|
|
49
57
|
"""Loads an image map for further reading.
|
|
50
58
|
|
|
51
59
|
:param file_name: The name of the image file.
|
|
@@ -55,53 +63,70 @@ def load_map(file_name: str, map_name: str, num_levels=4, sigma=1.0):
|
|
|
55
63
|
:param num_levels: The number of levels in the map pyramid
|
|
56
64
|
(default = 4). If num_levels == 0, the complete pyramid is
|
|
57
65
|
built.
|
|
66
|
+
:type num_levels: int
|
|
58
67
|
:param sigma: The sigma value of the gaussian function.
|
|
68
|
+
:type sigma: float
|
|
59
69
|
"""
|
|
60
70
|
|
|
61
71
|
...
|
|
62
72
|
|
|
63
|
-
def read_complete_view_map_pixel(level, x, y):
|
|
73
|
+
def read_complete_view_map_pixel(level: int, x: int, y: int) -> float:
|
|
64
74
|
"""Reads a pixel in the complete view map.
|
|
65
75
|
|
|
66
76
|
:param level: The level of the pyramid in which we wish to read the
|
|
67
77
|
pixel.
|
|
78
|
+
:type level: int
|
|
68
79
|
:param x: The x coordinate of the pixel we wish to read. The origin
|
|
69
80
|
is in the lower-left corner.
|
|
81
|
+
:type x: int
|
|
70
82
|
:param y: The y coordinate of the pixel we wish to read. The origin
|
|
71
83
|
is in the lower-left corner.
|
|
84
|
+
:type y: int
|
|
72
85
|
:return: The floating-point value stored for that pixel.
|
|
86
|
+
:rtype: float
|
|
73
87
|
"""
|
|
74
88
|
|
|
75
89
|
...
|
|
76
90
|
|
|
77
|
-
def read_directional_view_map_pixel(
|
|
91
|
+
def read_directional_view_map_pixel(
|
|
92
|
+
orientation: int, level: int, x: int, y: int
|
|
93
|
+
) -> float:
|
|
78
94
|
"""Reads a pixel in one of the oriented view map images.
|
|
79
95
|
|
|
80
96
|
:param orientation: The number telling which orientation we want to
|
|
81
97
|
check.
|
|
98
|
+
:type orientation: int
|
|
82
99
|
:param level: The level of the pyramid in which we wish to read the
|
|
83
100
|
pixel.
|
|
101
|
+
:type level: int
|
|
84
102
|
:param x: The x coordinate of the pixel we wish to read. The origin
|
|
85
103
|
is in the lower-left corner.
|
|
104
|
+
:type x: int
|
|
86
105
|
:param y: The y coordinate of the pixel we wish to read. The origin
|
|
87
106
|
is in the lower-left corner.
|
|
107
|
+
:type y: int
|
|
88
108
|
:return: The floating-point value stored for that pixel.
|
|
109
|
+
:rtype: float
|
|
89
110
|
"""
|
|
90
111
|
|
|
91
112
|
...
|
|
92
113
|
|
|
93
|
-
def read_map_pixel(map_name: str, level, x, y):
|
|
114
|
+
def read_map_pixel(map_name: str, level: int, x: int, y: int) -> float:
|
|
94
115
|
"""Reads a pixel in a user-defined map.
|
|
95
116
|
|
|
96
117
|
:param map_name: The name of the map.
|
|
97
118
|
:type map_name: str
|
|
98
119
|
:param level: The level of the pyramid in which we wish to read the
|
|
99
120
|
pixel.
|
|
121
|
+
:type level: int
|
|
100
122
|
:param x: The x coordinate of the pixel we wish to read. The origin
|
|
101
123
|
is in the lower-left corner.
|
|
124
|
+
:type x: int
|
|
102
125
|
:param y: The y coordinate of the pixel we wish to read. The origin
|
|
103
126
|
is in the lower-left corner.
|
|
127
|
+
:type y: int
|
|
104
128
|
:return: The floating-point value stored for that pixel.
|
|
129
|
+
:rtype: float
|
|
105
130
|
"""
|
|
106
131
|
|
|
107
132
|
...
|
freestyle/utils/__init__.pyi
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module contains helper functions used for Freestyle style module
|
|
3
|
+
writing.
|
|
4
|
+
|
|
5
|
+
freestyle.utils.ContextFunctions.rst
|
|
6
|
+
|
|
7
|
+
:maxdepth: 1
|
|
8
|
+
:caption: Submodules
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
|
|
1
12
|
import typing
|
|
2
13
|
import bpy.types
|
|
3
14
|
import freestyle.types
|
|
@@ -85,7 +96,7 @@ def integrate(
|
|
|
85
96
|
it: freestyle.types.Interface0DIterator,
|
|
86
97
|
it_end: freestyle.types.Interface0DIterator,
|
|
87
98
|
integration_type: freestyle.types.IntegrationType,
|
|
88
|
-
):
|
|
99
|
+
) -> typing.Union[int, float]:
|
|
89
100
|
"""Returns a single value from a set of values evaluated at each 0D
|
|
90
101
|
element of this 1D element.
|
|
91
102
|
|
|
@@ -106,6 +117,7 @@ def integrate(
|
|
|
106
117
|
value type is float if func is of the `UnaryFunction0DDouble`
|
|
107
118
|
or `UnaryFunction0DFloat` type, and int if func is of the
|
|
108
119
|
`UnaryFunction0DUnsigned` type.
|
|
120
|
+
:rtype: typing.Union[int, float]
|
|
109
121
|
"""
|
|
110
122
|
|
|
111
123
|
...
|
gpu/__init__.pyi
CHANGED
|
@@ -1,3 +1,228 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides Python wrappers for the GPU implementation in Blender.
|
|
3
|
+
Some higher level functions can be found in the gpu_extras module.
|
|
4
|
+
|
|
5
|
+
gpu.types.rst
|
|
6
|
+
gpu.matrix.rst
|
|
7
|
+
gpu.select.rst
|
|
8
|
+
gpu.shader.rst
|
|
9
|
+
gpu.state.rst
|
|
10
|
+
gpu.texture.rst
|
|
11
|
+
gpu.platform.rst
|
|
12
|
+
gpu.capabilities.rst
|
|
13
|
+
|
|
14
|
+
:maxdepth: 1
|
|
15
|
+
:caption: Submodules
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
--------------------
|
|
19
|
+
|
|
20
|
+
Geometry is drawn in batches.
|
|
21
|
+
A batch contains the necessary data to perform the drawing.
|
|
22
|
+
That includes an obligatory *Vertex Buffer* and an optional *Index Buffer*,
|
|
23
|
+
each of which is described in more detail in the following sections.
|
|
24
|
+
A batch also defines a draw type.
|
|
25
|
+
Typical draw types are POINTS, LINES and TRIS.
|
|
26
|
+
The draw type determines how the data will be interpreted and drawn.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
--------------------
|
|
30
|
+
|
|
31
|
+
A *Vertex Buffer Object* (VBO) (gpu.types.GPUVertBuf)
|
|
32
|
+
is an array that contains the vertex attributes needed for drawing using a specific shader.
|
|
33
|
+
Typical vertex attributes are *location*, *normal*, *color*, and *uv*.
|
|
34
|
+
Every vertex buffer has a *Vertex Format* (gpu.types.GPUVertFormat)
|
|
35
|
+
and a length corresponding to the number of vertices in the buffer.
|
|
36
|
+
A vertex format describes the attributes stored per vertex and their types.
|
|
37
|
+
|
|
38
|
+
The following code demonstrates the creation of a vertex buffer that contains 6 vertices.
|
|
39
|
+
For each vertex 2 attributes will be stored: The position and the normal.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
import gpu
|
|
43
|
+
vertex_positions = [(0, 0, 0), ...]
|
|
44
|
+
vertex_normals = [(0, 0, 1), ...]
|
|
45
|
+
|
|
46
|
+
fmt = gpu.types.GPUVertFormat()
|
|
47
|
+
fmt.attr_add(id="pos", comp_type='F32', len=3, fetch_mode='FLOAT')
|
|
48
|
+
fmt.attr_add(id="normal", comp_type='F32', len=3, fetch_mode='FLOAT')
|
|
49
|
+
|
|
50
|
+
vbo = gpu.types.GPUVertBuf(len=6, format=fmt)
|
|
51
|
+
vbo.attr_fill(id="pos", data=vertex_positions)
|
|
52
|
+
vbo.attr_fill(id="normal", data=vertex_normals)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This vertex buffer could be used to draw 6 points, 3 separate lines, 5 consecutive lines, 2 separate triangles, ...
|
|
56
|
+
E.g. in the case of lines, each two consecutive vertices define a line.
|
|
57
|
+
The type that will actually be drawn is determined when the batch is created later.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
--------------------
|
|
61
|
+
|
|
62
|
+
Often triangles and lines share one or more vertices.
|
|
63
|
+
With only a vertex buffer one would have to store all attributes for the these vertices multiple times.
|
|
64
|
+
This is very inefficient because in a connected triangle mesh every vertex is used 6 times on average.
|
|
65
|
+
A more efficient approach would be to use an *Index Buffer* (IBO) (gpu.types.GPUIndexBuf),
|
|
66
|
+
sometimes referred to as *Element Buffer*.
|
|
67
|
+
An *Index Buffer* is an array that references vertices based on their index in the vertex buffer.
|
|
68
|
+
|
|
69
|
+
For instance, to draw a rectangle composed of two triangles, one could use an index buffer.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
positions = (
|
|
73
|
+
(-1, 1), (1, 1),
|
|
74
|
+
(-1, -1), (1, -1))
|
|
75
|
+
|
|
76
|
+
indices = ((0, 1, 2), (2, 1, 3))
|
|
77
|
+
|
|
78
|
+
ibo = gpu.types.GPUIndexBuf(type='TRIS', seq=indices)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Here the first tuple in indices describes which vertices should be used for the first triangle
|
|
82
|
+
(same for the second tuple).
|
|
83
|
+
Note how the diagonal vertices 1 and 2 are shared between both triangles.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
--------------------
|
|
87
|
+
|
|
88
|
+
A shader is a program that runs on the GPU (written in GLSL in our case).
|
|
89
|
+
There are multiple types of shaders.
|
|
90
|
+
The most important ones are *Vertex Shaders* and *Fragment Shaders*.
|
|
91
|
+
Typically multiple shaders are linked together into a *Program*.
|
|
92
|
+
However, in the Blender Python API the term *Shader* refers to an OpenGL Program.
|
|
93
|
+
Every gpu.types.GPUShader consists of a vertex shader, a fragment shader and an optional geometry shader.
|
|
94
|
+
For common drawing tasks there are some built-in shaders accessible from gpu.shader.from_builtin
|
|
95
|
+
with an identifier such as UNIFORM_COLOR or FLAT_COLOR.
|
|
96
|
+
|
|
97
|
+
Every shader defines a set of attributes and uniforms that have to be set in order to use the shader.
|
|
98
|
+
Attributes are properties that are set using a vertex buffer and can be different for individual vertices.
|
|
99
|
+
Uniforms are properties that are constant per draw call.
|
|
100
|
+
They can be set using the shader.uniform_* functions after the shader has been bound.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
--------------------
|
|
104
|
+
|
|
105
|
+
Batches can be creates by first manually creating VBOs and IBOs.
|
|
106
|
+
However, it is recommended to use the gpu_extras.batch.batch_for_shader function.
|
|
107
|
+
It makes sure that all the vertex attributes necessary for a specific shader are provided.
|
|
108
|
+
Consequently, the shader has to be passed to the function as well.
|
|
109
|
+
When using this function one rarely has to care about the vertex format, VBOs and IBOs created in the background.
|
|
110
|
+
This is still something one should know when drawing stuff though.
|
|
111
|
+
|
|
112
|
+
Since batches can be drawn multiple times, they should be cached and reused whenever possible.
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
--------------------
|
|
116
|
+
|
|
117
|
+
What one can see on the screen after rendering is called the *Front Buffer*.
|
|
118
|
+
When draw calls are issued, batches are drawn on a *Back Buffer* that will only be displayed
|
|
119
|
+
when all drawing is done and the current back buffer will become the new front buffer.
|
|
120
|
+
Sometimes, one might want to draw the batches into a distinct buffer that could be used as
|
|
121
|
+
texture to display on another object or to be saved as image on disk.
|
|
122
|
+
This is called Offscreen Rendering.
|
|
123
|
+
In Blender Offscreen Rendering is done using the gpu.types.GPUOffScreen type.
|
|
124
|
+
|
|
125
|
+
[WARNING]
|
|
126
|
+
GPUOffScreen objects are bound to the OpenGL context they have been created in.
|
|
127
|
+
This means that once Blender discards this context (i.e. the window is closed),
|
|
128
|
+
the offscreen instance will be freed.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
--------------------
|
|
132
|
+
|
|
133
|
+
To try these examples, just copy them into Blenders text editor and execute them.
|
|
134
|
+
To keep the examples relatively small, they just register a draw function that can't easily be removed anymore.
|
|
135
|
+
Blender has to be restarted in order to delete the draw handlers.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
--------------------
|
|
139
|
+
|
|
140
|
+
```../examples/gpu.1.py```
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
--------------------
|
|
144
|
+
|
|
145
|
+
```../examples/gpu.2.py```
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
--------------------
|
|
149
|
+
|
|
150
|
+
```../examples/gpu.3.py```
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
--------------------
|
|
154
|
+
|
|
155
|
+
```../examples/gpu.4.py```
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
--------------------
|
|
159
|
+
|
|
160
|
+
```../examples/gpu.5.py```
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
--------------------
|
|
164
|
+
|
|
165
|
+
To use this example you have to provide an image that should be displayed.
|
|
166
|
+
|
|
167
|
+
```../examples/gpu.6.py```
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
--------------------
|
|
171
|
+
|
|
172
|
+
1. Create an gpu.types.GPUOffScreen object.
|
|
173
|
+
2. Draw some circles into it.
|
|
174
|
+
3. Make a new shader for drawing a planar texture in 3D.
|
|
175
|
+
4. Draw the generated texture using the new shader.
|
|
176
|
+
|
|
177
|
+
```../examples/gpu.7.py```
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
--------------------
|
|
181
|
+
|
|
182
|
+
This will create a new image with the given name.
|
|
183
|
+
If it already exists, it will override the existing one.
|
|
184
|
+
|
|
185
|
+
Currently almost all of the execution time is spent in the last line.
|
|
186
|
+
In the future this will hopefully be solved by implementing the Python buffer protocol
|
|
187
|
+
for gpu.types.Buffer and bpy.types.Image.pixels (aka bpy_prop_array
|
|
188
|
+
|
|
189
|
+
).
|
|
190
|
+
|
|
191
|
+
```../examples/gpu.8.py```
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
--------------------
|
|
195
|
+
|
|
196
|
+
The scene has to have a camera for this example to work.
|
|
197
|
+
You could also make this independent of a specific camera,
|
|
198
|
+
but Blender does not expose good functions to create view and projection matrices yet.
|
|
199
|
+
|
|
200
|
+
```../examples/gpu.9.py```
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
--------------------
|
|
204
|
+
|
|
205
|
+
In this example the arc length (distance to the first point on the line) is calculated in every vertex.
|
|
206
|
+
Between the vertex and fragment shader that value is automatically interpolated
|
|
207
|
+
for all points that will be visible on the screen.
|
|
208
|
+
In the fragment shader the sin
|
|
209
|
+
|
|
210
|
+
of the arc length is calculated.
|
|
211
|
+
Based on the result a decision is made on whether the fragment should be drawn or not.
|
|
212
|
+
|
|
213
|
+
```../examples/gpu.10.py```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
--------------------
|
|
217
|
+
|
|
218
|
+
This is an example of how to use a custom compute shader to write to a texture and then use that texture in a vertex/fragment shader.
|
|
219
|
+
The expected result is a 2x2 plane (size of the default cube), which changes color from a green-black gradient to a green-red gradient,
|
|
220
|
+
based on current time.
|
|
221
|
+
|
|
222
|
+
```../examples/gpu.11.py```
|
|
223
|
+
|
|
224
|
+
"""
|
|
225
|
+
|
|
1
226
|
import typing
|
|
2
227
|
from . import capabilities
|
|
3
228
|
from . import matrix
|
gpu/capabilities/__init__.pyi
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides access to the GPU capabilities.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
1
6
|
import typing
|
|
2
7
|
|
|
3
8
|
GenericType = typing.TypeVar("GenericType")
|
|
@@ -28,133 +33,150 @@ def hdr_support_get() -> bool:
|
|
|
28
33
|
|
|
29
34
|
...
|
|
30
35
|
|
|
31
|
-
def max_batch_indices_get():
|
|
36
|
+
def max_batch_indices_get() -> int:
|
|
32
37
|
"""Get maximum number of vertex array indices.
|
|
33
38
|
|
|
34
39
|
:return: Number of indices.
|
|
40
|
+
:rtype: int
|
|
35
41
|
"""
|
|
36
42
|
|
|
37
43
|
...
|
|
38
44
|
|
|
39
|
-
def max_batch_vertices_get():
|
|
45
|
+
def max_batch_vertices_get() -> int:
|
|
40
46
|
"""Get maximum number of vertex array vertices.
|
|
41
47
|
|
|
42
48
|
:return: Number of vertices.
|
|
49
|
+
:rtype: int
|
|
43
50
|
"""
|
|
44
51
|
|
|
45
52
|
...
|
|
46
53
|
|
|
47
|
-
def max_images_get():
|
|
54
|
+
def max_images_get() -> int:
|
|
48
55
|
"""Get maximum supported number of image units.
|
|
49
56
|
|
|
50
57
|
:return: Number of image units.
|
|
58
|
+
:rtype: int
|
|
51
59
|
"""
|
|
52
60
|
|
|
53
61
|
...
|
|
54
62
|
|
|
55
|
-
def max_texture_layers_get():
|
|
63
|
+
def max_texture_layers_get() -> int:
|
|
56
64
|
"""Get maximum number of layers in texture.
|
|
57
65
|
|
|
58
66
|
:return: Number of layers.
|
|
67
|
+
:rtype: int
|
|
59
68
|
"""
|
|
60
69
|
|
|
61
70
|
...
|
|
62
71
|
|
|
63
|
-
def max_texture_size_get():
|
|
72
|
+
def max_texture_size_get() -> int:
|
|
64
73
|
"""Get estimated maximum texture size to be able to handle.
|
|
65
74
|
|
|
66
75
|
:return: Texture size.
|
|
76
|
+
:rtype: int
|
|
67
77
|
"""
|
|
68
78
|
|
|
69
79
|
...
|
|
70
80
|
|
|
71
|
-
def max_textures_frag_get():
|
|
81
|
+
def max_textures_frag_get() -> int:
|
|
72
82
|
"""Get maximum supported texture image units used for
|
|
73
83
|
accessing texture maps from the fragment shader.
|
|
74
84
|
|
|
75
85
|
:return: Texture image units.
|
|
86
|
+
:rtype: int
|
|
76
87
|
"""
|
|
77
88
|
|
|
78
89
|
...
|
|
79
90
|
|
|
80
|
-
def max_textures_geom_get():
|
|
91
|
+
def max_textures_geom_get() -> int:
|
|
81
92
|
"""Get maximum supported texture image units used for
|
|
82
93
|
accessing texture maps from the geometry shader.
|
|
83
94
|
|
|
84
95
|
:return: Texture image units.
|
|
96
|
+
:rtype: int
|
|
85
97
|
"""
|
|
86
98
|
|
|
87
99
|
...
|
|
88
100
|
|
|
89
|
-
def max_textures_get():
|
|
101
|
+
def max_textures_get() -> int:
|
|
90
102
|
"""Get maximum supported texture image units used for
|
|
91
103
|
accessing texture maps from the vertex shader and the
|
|
92
104
|
fragment processor.
|
|
93
105
|
|
|
94
106
|
:return: Texture image units.
|
|
107
|
+
:rtype: int
|
|
95
108
|
"""
|
|
96
109
|
|
|
97
110
|
...
|
|
98
111
|
|
|
99
|
-
def max_textures_vert_get():
|
|
112
|
+
def max_textures_vert_get() -> int:
|
|
100
113
|
"""Get maximum supported texture image units used for
|
|
101
114
|
accessing texture maps from the vertex shader.
|
|
102
115
|
|
|
103
116
|
:return: Texture image units.
|
|
117
|
+
:rtype: int
|
|
104
118
|
"""
|
|
105
119
|
|
|
106
120
|
...
|
|
107
121
|
|
|
108
|
-
def max_uniforms_frag_get():
|
|
122
|
+
def max_uniforms_frag_get() -> int:
|
|
109
123
|
"""Get maximum number of values held in uniform variable
|
|
110
124
|
storage for a fragment shader.
|
|
111
125
|
|
|
112
126
|
:return: Number of values.
|
|
127
|
+
:rtype: int
|
|
113
128
|
"""
|
|
114
129
|
|
|
115
130
|
...
|
|
116
131
|
|
|
117
|
-
def max_uniforms_vert_get():
|
|
132
|
+
def max_uniforms_vert_get() -> int:
|
|
118
133
|
"""Get maximum number of values held in uniform variable
|
|
119
134
|
storage for a vertex shader.
|
|
120
135
|
|
|
121
136
|
:return: Number of values.
|
|
137
|
+
:rtype: int
|
|
122
138
|
"""
|
|
123
139
|
|
|
124
140
|
...
|
|
125
141
|
|
|
126
|
-
def max_varying_floats_get():
|
|
142
|
+
def max_varying_floats_get() -> int:
|
|
127
143
|
"""Get maximum number of varying variables used by
|
|
128
144
|
vertex and fragment shaders.
|
|
129
145
|
|
|
130
146
|
:return: Number of variables.
|
|
147
|
+
:rtype: int
|
|
131
148
|
"""
|
|
132
149
|
|
|
133
150
|
...
|
|
134
151
|
|
|
135
|
-
def max_vertex_attribs_get():
|
|
152
|
+
def max_vertex_attribs_get() -> int:
|
|
136
153
|
"""Get maximum number of vertex attributes accessible to
|
|
137
154
|
a vertex shader.
|
|
138
155
|
|
|
139
156
|
:return: Number of attributes.
|
|
157
|
+
:rtype: int
|
|
140
158
|
"""
|
|
141
159
|
|
|
142
160
|
...
|
|
143
161
|
|
|
144
|
-
def max_work_group_count_get(index):
|
|
162
|
+
def max_work_group_count_get(index: int) -> int:
|
|
145
163
|
"""Get maximum number of work groups that may be dispatched to a compute shader.
|
|
146
164
|
|
|
147
165
|
:param index: Index of the dimension.
|
|
166
|
+
:type index: int
|
|
148
167
|
:return: Maximum number of work groups for the queried dimension.
|
|
168
|
+
:rtype: int
|
|
149
169
|
"""
|
|
150
170
|
|
|
151
171
|
...
|
|
152
172
|
|
|
153
|
-
def max_work_group_size_get(index):
|
|
173
|
+
def max_work_group_size_get(index: int) -> int:
|
|
154
174
|
"""Get maximum size of a work group that may be dispatched to a compute shader.
|
|
155
175
|
|
|
156
176
|
:param index: Index of the dimension.
|
|
177
|
+
:type index: int
|
|
157
178
|
:return: Maximum size of a work group for the queried dimension.
|
|
179
|
+
:rtype: int
|
|
158
180
|
"""
|
|
159
181
|
|
|
160
182
|
...
|
gpu/matrix/__init__.pyi
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides access to the matrix stack.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
1
6
|
import typing
|
|
2
7
|
import mathutils
|
|
3
8
|
|
|
@@ -107,10 +112,11 @@ def scale(scale):
|
|
|
107
112
|
|
|
108
113
|
...
|
|
109
114
|
|
|
110
|
-
def scale_uniform(scale):
|
|
115
|
+
def scale_uniform(scale: float):
|
|
111
116
|
"""
|
|
112
117
|
|
|
113
118
|
:param scale: Scale the current stack matrix.
|
|
119
|
+
:type scale: float
|
|
114
120
|
"""
|
|
115
121
|
|
|
116
122
|
...
|
gpu/platform/__init__.pyi
CHANGED
gpu/select/__init__.pyi
CHANGED
gpu/shader/__init__.pyi
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides access to GPUShader internal functions.
|
|
3
|
+
|
|
4
|
+
Built-in shaders
|
|
5
|
+
|
|
6
|
+
All built-in shaders have the mat4 ModelViewProjectionMatrix
|
|
7
|
+
|
|
8
|
+
uniform.
|
|
9
|
+
|
|
10
|
+
Its value must be modified using the gpu.matrix module.
|
|
11
|
+
|
|
12
|
+
FLAT_COLOR
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Attributes: vec3 pos, vec4 color
|
|
16
|
+
Uniforms: none
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
IMAGE
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Attributes: vec3 pos, vec2 texCoord
|
|
24
|
+
Uniforms: sampler2D image
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
IMAGE_COLOR
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Attributes: vec3 pos, vec2 texCoord
|
|
32
|
+
Uniforms: sampler2D image, vec4 color
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
SMOOTH_COLOR
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Attributes: vec3 pos, vec4 color
|
|
40
|
+
Uniforms: none
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
UNIFORM_COLOR
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
Attributes: vec3 pos
|
|
48
|
+
Uniforms: vec4 color
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
POLYLINE_FLAT_COLOR
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Attributes: vec3 pos, vec4 color
|
|
56
|
+
Uniforms: vec2 viewportSize, float lineWidth
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
POLYLINE_SMOOTH_COLOR
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Attributes: vec3 pos, vec4 color
|
|
64
|
+
Uniforms: vec2 viewportSize, float lineWidth
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
POLYLINE_UNIFORM_COLOR
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Attributes: vec3 pos
|
|
72
|
+
Uniforms: vec2 viewportSize, float lineWidth
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
|
|
1
78
|
import typing
|
|
2
79
|
|
|
3
80
|
GenericType = typing.TypeVar("GenericType")
|