gstaichi 0.1.18.dev1__cp310-cp310-win_amd64.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.
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools/cmake/SPIRV-ToolsConfig.cmake +5 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget-release.cmake +29 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget.cmake +113 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffConfig.cmake +5 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets-release.cmake +19 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets.cmake +122 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkConfig.cmake +5 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets-release.cmake +19 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets.cmake +122 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintConfig.cmake +5 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets-release.cmake +19 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets.cmake +122 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optConfig.cmake +5 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets-release.cmake +19 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets.cmake +122 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceConfig.cmake +5 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget-release.cmake +19 -0
- gstaichi-0.1.18.dev1.data/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget.cmake +122 -0
- gstaichi-0.1.18.dev1.data/data/bin/SPIRV-Tools-shared.dll +0 -0
- gstaichi-0.1.18.dev1.data/data/include/GLFW/glfw3.h +6389 -0
- gstaichi-0.1.18.dev1.data/data/include/GLFW/glfw3native.h +594 -0
- gstaichi-0.1.18.dev1.data/data/include/spirv-tools/instrument.hpp +268 -0
- gstaichi-0.1.18.dev1.data/data/include/spirv-tools/libspirv.h +907 -0
- gstaichi-0.1.18.dev1.data/data/include/spirv-tools/libspirv.hpp +375 -0
- gstaichi-0.1.18.dev1.data/data/include/spirv-tools/linker.hpp +97 -0
- gstaichi-0.1.18.dev1.data/data/include/spirv-tools/optimizer.hpp +970 -0
- gstaichi-0.1.18.dev1.data/data/lib/SPIRV-Tools-diff.lib +0 -0
- gstaichi-0.1.18.dev1.data/data/lib/SPIRV-Tools-link.lib +0 -0
- gstaichi-0.1.18.dev1.data/data/lib/SPIRV-Tools-lint.lib +0 -0
- gstaichi-0.1.18.dev1.data/data/lib/SPIRV-Tools-opt.lib +0 -0
- gstaichi-0.1.18.dev1.data/data/lib/SPIRV-Tools-reduce.lib +0 -0
- gstaichi-0.1.18.dev1.data/data/lib/SPIRV-Tools-shared.lib +0 -0
- gstaichi-0.1.18.dev1.data/data/lib/SPIRV-Tools.lib +0 -0
- gstaichi-0.1.18.dev1.data/data/lib/cmake/glfw3/glfw3Config.cmake +3 -0
- gstaichi-0.1.18.dev1.data/data/lib/cmake/glfw3/glfw3ConfigVersion.cmake +65 -0
- gstaichi-0.1.18.dev1.data/data/lib/cmake/glfw3/glfw3Targets-release.cmake +19 -0
- gstaichi-0.1.18.dev1.data/data/lib/cmake/glfw3/glfw3Targets.cmake +107 -0
- gstaichi-0.1.18.dev1.data/data/lib/glfw3.lib +0 -0
- gstaichi-0.1.18.dev1.dist-info/METADATA +108 -0
- gstaichi-0.1.18.dev1.dist-info/RECORD +198 -0
- gstaichi-0.1.18.dev1.dist-info/WHEEL +5 -0
- gstaichi-0.1.18.dev1.dist-info/entry_points.txt +2 -0
- gstaichi-0.1.18.dev1.dist-info/licenses/LICENSE +201 -0
- gstaichi-0.1.18.dev1.dist-info/top_level.txt +1 -0
- taichi/CHANGELOG.md +15 -0
- taichi/__init__.py +44 -0
- taichi/__main__.py +5 -0
- taichi/_funcs.py +706 -0
- taichi/_kernels.py +420 -0
- taichi/_lib/__init__.py +3 -0
- taichi/_lib/c_api/bin/taichi_c_api.dll +0 -0
- taichi/_lib/c_api/include/taichi/cpp/taichi.hpp +1401 -0
- taichi/_lib/c_api/include/taichi/taichi.h +29 -0
- taichi/_lib/c_api/include/taichi/taichi_core.h +1111 -0
- taichi/_lib/c_api/include/taichi/taichi_cpu.h +29 -0
- taichi/_lib/c_api/include/taichi/taichi_cuda.h +36 -0
- taichi/_lib/c_api/include/taichi/taichi_platform.h +55 -0
- taichi/_lib/c_api/include/taichi/taichi_unity.h +64 -0
- taichi/_lib/c_api/include/taichi/taichi_vulkan.h +151 -0
- taichi/_lib/c_api/lib/taichi_c_api.lib +0 -0
- taichi/_lib/c_api/runtime/runtime_cuda.bc +0 -0
- taichi/_lib/c_api/runtime/runtime_x64.bc +0 -0
- taichi/_lib/c_api/runtime/slim_libdevice.10.bc +0 -0
- taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiConfig.cmake +29 -0
- taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiConfigVersion.cmake +65 -0
- taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiTargets.cmake +121 -0
- taichi/_lib/core/__init__.py +0 -0
- taichi/_lib/core/py.typed +0 -0
- taichi/_lib/core/taichi_python.cp310-win_amd64.pyd +0 -0
- taichi/_lib/core/taichi_python.pyi +3077 -0
- taichi/_lib/runtime/runtime_cuda.bc +0 -0
- taichi/_lib/runtime/runtime_x64.bc +0 -0
- taichi/_lib/runtime/slim_libdevice.10.bc +0 -0
- taichi/_lib/utils.py +249 -0
- taichi/_logging.py +131 -0
- taichi/_main.py +552 -0
- taichi/_snode/__init__.py +5 -0
- taichi/_snode/fields_builder.py +189 -0
- taichi/_snode/snode_tree.py +34 -0
- taichi/_ti_module/__init__.py +3 -0
- taichi/_ti_module/cppgen.py +309 -0
- taichi/_ti_module/module.py +145 -0
- taichi/_version.py +1 -0
- taichi/_version_check.py +100 -0
- taichi/ad/__init__.py +3 -0
- taichi/ad/_ad.py +530 -0
- taichi/algorithms/__init__.py +3 -0
- taichi/algorithms/_algorithms.py +117 -0
- taichi/aot/__init__.py +12 -0
- taichi/aot/_export.py +28 -0
- taichi/aot/conventions/__init__.py +3 -0
- taichi/aot/conventions/gfxruntime140/__init__.py +38 -0
- taichi/aot/conventions/gfxruntime140/dr.py +244 -0
- taichi/aot/conventions/gfxruntime140/sr.py +613 -0
- taichi/aot/module.py +253 -0
- taichi/aot/utils.py +151 -0
- taichi/assets/.git +1 -0
- taichi/assets/Go-Regular.ttf +0 -0
- taichi/assets/static/imgs/ti_gallery.png +0 -0
- taichi/examples/minimal.py +28 -0
- taichi/experimental.py +16 -0
- taichi/graph/__init__.py +3 -0
- taichi/graph/_graph.py +292 -0
- taichi/lang/__init__.py +50 -0
- taichi/lang/_ndarray.py +348 -0
- taichi/lang/_ndrange.py +152 -0
- taichi/lang/_texture.py +172 -0
- taichi/lang/_wrap_inspect.py +189 -0
- taichi/lang/any_array.py +99 -0
- taichi/lang/argpack.py +411 -0
- taichi/lang/ast/__init__.py +5 -0
- taichi/lang/ast/ast_transformer.py +1806 -0
- taichi/lang/ast/ast_transformer_utils.py +328 -0
- taichi/lang/ast/checkers.py +106 -0
- taichi/lang/ast/symbol_resolver.py +57 -0
- taichi/lang/ast/transform.py +9 -0
- taichi/lang/common_ops.py +310 -0
- taichi/lang/exception.py +80 -0
- taichi/lang/expr.py +180 -0
- taichi/lang/field.py +464 -0
- taichi/lang/impl.py +1246 -0
- taichi/lang/kernel_arguments.py +157 -0
- taichi/lang/kernel_impl.py +1415 -0
- taichi/lang/matrix.py +1877 -0
- taichi/lang/matrix_ops.py +341 -0
- taichi/lang/matrix_ops_utils.py +190 -0
- taichi/lang/mesh.py +687 -0
- taichi/lang/misc.py +807 -0
- taichi/lang/ops.py +1489 -0
- taichi/lang/runtime_ops.py +13 -0
- taichi/lang/shell.py +35 -0
- taichi/lang/simt/__init__.py +5 -0
- taichi/lang/simt/block.py +94 -0
- taichi/lang/simt/grid.py +7 -0
- taichi/lang/simt/subgroup.py +191 -0
- taichi/lang/simt/warp.py +96 -0
- taichi/lang/snode.py +487 -0
- taichi/lang/source_builder.py +150 -0
- taichi/lang/struct.py +855 -0
- taichi/lang/util.py +381 -0
- taichi/linalg/__init__.py +8 -0
- taichi/linalg/matrixfree_cg.py +310 -0
- taichi/linalg/sparse_cg.py +59 -0
- taichi/linalg/sparse_matrix.py +303 -0
- taichi/linalg/sparse_solver.py +123 -0
- taichi/math/__init__.py +11 -0
- taichi/math/_complex.py +204 -0
- taichi/math/mathimpl.py +886 -0
- taichi/profiler/__init__.py +6 -0
- taichi/profiler/kernel_metrics.py +260 -0
- taichi/profiler/kernel_profiler.py +592 -0
- taichi/profiler/memory_profiler.py +15 -0
- taichi/profiler/scoped_profiler.py +36 -0
- taichi/shaders/Circles_vk.frag +29 -0
- taichi/shaders/Circles_vk.vert +45 -0
- taichi/shaders/Circles_vk_frag.spv +0 -0
- taichi/shaders/Circles_vk_vert.spv +0 -0
- taichi/shaders/Lines_vk.frag +9 -0
- taichi/shaders/Lines_vk.vert +11 -0
- taichi/shaders/Lines_vk_frag.spv +0 -0
- taichi/shaders/Lines_vk_vert.spv +0 -0
- taichi/shaders/Mesh_vk.frag +71 -0
- taichi/shaders/Mesh_vk.vert +68 -0
- taichi/shaders/Mesh_vk_frag.spv +0 -0
- taichi/shaders/Mesh_vk_vert.spv +0 -0
- taichi/shaders/Particles_vk.frag +95 -0
- taichi/shaders/Particles_vk.vert +73 -0
- taichi/shaders/Particles_vk_frag.spv +0 -0
- taichi/shaders/Particles_vk_vert.spv +0 -0
- taichi/shaders/SceneLines2quad_vk_comp.spv +0 -0
- taichi/shaders/SceneLines_vk.frag +9 -0
- taichi/shaders/SceneLines_vk.vert +12 -0
- taichi/shaders/SceneLines_vk_frag.spv +0 -0
- taichi/shaders/SceneLines_vk_vert.spv +0 -0
- taichi/shaders/SetImage_vk.frag +21 -0
- taichi/shaders/SetImage_vk.vert +15 -0
- taichi/shaders/SetImage_vk_frag.spv +0 -0
- taichi/shaders/SetImage_vk_vert.spv +0 -0
- taichi/shaders/Triangles_vk.frag +16 -0
- taichi/shaders/Triangles_vk.vert +29 -0
- taichi/shaders/Triangles_vk_frag.spv +0 -0
- taichi/shaders/Triangles_vk_vert.spv +0 -0
- taichi/shaders/lines2quad_vk_comp.spv +0 -0
- taichi/sparse/__init__.py +3 -0
- taichi/sparse/_sparse_grid.py +77 -0
- taichi/tools/__init__.py +12 -0
- taichi/tools/diagnose.py +124 -0
- taichi/tools/np2ply.py +364 -0
- taichi/tools/vtk.py +38 -0
- taichi/types/__init__.py +19 -0
- taichi/types/annotations.py +47 -0
- taichi/types/compound_types.py +90 -0
- taichi/types/enums.py +49 -0
- taichi/types/ndarray_type.py +147 -0
- taichi/types/primitive_types.py +203 -0
- taichi/types/quant.py +88 -0
- taichi/types/texture_type.py +85 -0
- taichi/types/utils.py +13 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(location = 0) in vec3 in_position;
|
4
|
+
layout(location = 1) in vec3 in_normal;
|
5
|
+
layout(location = 2) in vec2 in_texcoord;
|
6
|
+
layout(location = 3) in vec4 in_color;
|
7
|
+
|
8
|
+
layout(binding = 0) uniform UBO {
|
9
|
+
vec3 color;
|
10
|
+
int use_per_vertex_color;
|
11
|
+
int use_per_vertex_radius;
|
12
|
+
float radius;
|
13
|
+
float window_width;
|
14
|
+
float window_height;
|
15
|
+
}
|
16
|
+
ubo;
|
17
|
+
|
18
|
+
layout(location = 1) out vec3 selected_color;
|
19
|
+
layout(location = 2) out vec2 pos_2d;
|
20
|
+
|
21
|
+
const vec2 offsets[6] = {
|
22
|
+
vec2(-1.0f, 1.0f),
|
23
|
+
vec2(1.0f, -1.0f),
|
24
|
+
vec2(-1.0f, -1.0f),
|
25
|
+
vec2(-1.0f, 1.0f),
|
26
|
+
vec2(1.0f, 1.0f),
|
27
|
+
vec2(1.0f, -1.0f),
|
28
|
+
};
|
29
|
+
|
30
|
+
void main() {
|
31
|
+
float x = in_position.x * 2.0 - 1.0;
|
32
|
+
float y = -(in_position.y * 2.0 - 1.0);
|
33
|
+
|
34
|
+
pos_2d = offsets[gl_VertexIndex % 6];
|
35
|
+
float radius_1d = ubo.use_per_vertex_radius == 0 ? ubo.radius : in_normal.x;
|
36
|
+
|
37
|
+
gl_Position = vec4(x, y, 0.0, 1.0);
|
38
|
+
gl_Position.xy += pos_2d * vec2(radius_1d / ubo.window_width * ubo.window_height, radius_1d) * 2.0;
|
39
|
+
|
40
|
+
if (ubo.use_per_vertex_color == 0) {
|
41
|
+
selected_color = ubo.color;
|
42
|
+
} else {
|
43
|
+
selected_color = in_color.rgb;
|
44
|
+
}
|
45
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(location = 0) in vec2 in_position;
|
4
|
+
layout(location = 1) in uint in_color_encoded;
|
5
|
+
|
6
|
+
layout(location = 0) out vec3 frag_color;
|
7
|
+
|
8
|
+
void main() {
|
9
|
+
gl_Position = vec4(in_position.x * 2.0 - 1.0, -(in_position.y * 2.0 - 1.0), 0.0, 1.0);
|
10
|
+
frag_color = unpackUnorm4x8(in_color_encoded).rgb;
|
11
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(location = 0) in vec3 frag_pos;
|
4
|
+
layout(location = 1) in vec3 frag_normal;
|
5
|
+
layout(location = 2) in vec2 frag_texcoord;
|
6
|
+
|
7
|
+
layout(location = 0) out vec4 out_color;
|
8
|
+
|
9
|
+
struct SceneUBO {
|
10
|
+
vec3 camera_pos;
|
11
|
+
mat4 view;
|
12
|
+
mat4 projection;
|
13
|
+
vec3 ambient_light;
|
14
|
+
int point_light_count;
|
15
|
+
};
|
16
|
+
|
17
|
+
layout(binding = 0) uniform UBORenderable {
|
18
|
+
vec3 color;
|
19
|
+
int use_per_vertex_color;
|
20
|
+
int two_sided;
|
21
|
+
float has_attribute;
|
22
|
+
}
|
23
|
+
ubo_renderable;
|
24
|
+
|
25
|
+
layout(binding = 1) uniform UBOScene {
|
26
|
+
SceneUBO scene;
|
27
|
+
float window_width;
|
28
|
+
float window_height;
|
29
|
+
float tan_half_fov;
|
30
|
+
float aspect_ratio;
|
31
|
+
}
|
32
|
+
ubo_scene;
|
33
|
+
|
34
|
+
struct PointLight {
|
35
|
+
vec3 pos;
|
36
|
+
vec3 color;
|
37
|
+
};
|
38
|
+
|
39
|
+
layout(binding = 2, std430) buffer SSBO {
|
40
|
+
PointLight point_lights[];
|
41
|
+
}
|
42
|
+
ssbo;
|
43
|
+
|
44
|
+
layout(location = 3) in vec4 selected_color;
|
45
|
+
|
46
|
+
vec3 lambertian() {
|
47
|
+
vec3 ambient = ubo_scene.scene.ambient_light * selected_color.rgb;
|
48
|
+
vec3 result = ambient;
|
49
|
+
|
50
|
+
for (int i = 0; i < ubo_scene.scene.point_light_count; ++i) {
|
51
|
+
vec3 light_color = ssbo.point_lights[i].color;
|
52
|
+
|
53
|
+
vec3 light_dir = normalize(ssbo.point_lights[i].pos - frag_pos);
|
54
|
+
vec3 normal = normalize(frag_normal);
|
55
|
+
float factor = 0.0;
|
56
|
+
if(ubo_renderable.two_sided != 0){
|
57
|
+
factor = abs(dot(light_dir, normal));
|
58
|
+
}
|
59
|
+
else{
|
60
|
+
factor = max(dot(light_dir, normal), 0);
|
61
|
+
}
|
62
|
+
vec3 diffuse = factor * selected_color.rgb * light_color;
|
63
|
+
result += diffuse;
|
64
|
+
}
|
65
|
+
|
66
|
+
return result;
|
67
|
+
}
|
68
|
+
|
69
|
+
void main() {
|
70
|
+
out_color = vec4(lambertian(), selected_color.a);
|
71
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(location = 0) in vec3 in_position;
|
4
|
+
layout(location = 1) in vec3 in_normal;
|
5
|
+
layout(location = 2) in vec2 in_texcoord;
|
6
|
+
layout(location = 3) in vec4 in_color;
|
7
|
+
|
8
|
+
layout(location = 0) out vec3 frag_pos;
|
9
|
+
layout(location = 1) out vec3 frag_normal;
|
10
|
+
layout(location = 2) out vec2 frag_texcoord;
|
11
|
+
layout(location = 3) out vec4 selected_color;
|
12
|
+
|
13
|
+
struct SceneUBO {
|
14
|
+
vec3 camera_pos;
|
15
|
+
mat4 view;
|
16
|
+
mat4 projection;
|
17
|
+
vec3 ambient_light;
|
18
|
+
int point_light_count;
|
19
|
+
};
|
20
|
+
|
21
|
+
struct PointLight {
|
22
|
+
vec3 pos;
|
23
|
+
vec3 color;
|
24
|
+
};
|
25
|
+
|
26
|
+
struct MeshAttribute {
|
27
|
+
mat4 model;
|
28
|
+
};
|
29
|
+
|
30
|
+
layout(binding = 0) uniform UBORenderable {
|
31
|
+
vec3 color;
|
32
|
+
int use_per_vertex_color;
|
33
|
+
int two_sided;
|
34
|
+
float has_attribute;
|
35
|
+
}
|
36
|
+
ubo_renderable;
|
37
|
+
|
38
|
+
layout(binding = 1) uniform UBOScene {
|
39
|
+
SceneUBO scene;
|
40
|
+
float window_width;
|
41
|
+
float window_height;
|
42
|
+
float tan_half_fov;
|
43
|
+
float aspect_ratio;
|
44
|
+
}
|
45
|
+
ubo_scene;
|
46
|
+
|
47
|
+
layout(binding = 3, std430) buffer MeshAttributeBuffer {
|
48
|
+
MeshAttribute mesh_attr[];
|
49
|
+
}
|
50
|
+
mesh_attr_buffer;
|
51
|
+
|
52
|
+
void main() {
|
53
|
+
mat4 model_tmp = transpose(mesh_attr_buffer.mesh_attr[gl_InstanceIndex].model);
|
54
|
+
// if mesh attributes not given, then use Identity as model matrix
|
55
|
+
mat4 model = mat4(1.0) * (1.0 - ubo_renderable.has_attribute) + model_tmp * ubo_renderable.has_attribute;
|
56
|
+
|
57
|
+
gl_Position = ubo_scene.scene.projection * ubo_scene.scene.view * model * vec4(in_position, 1.0);
|
58
|
+
gl_Position.y *= -1.0;
|
59
|
+
frag_texcoord = in_texcoord;
|
60
|
+
frag_pos = in_position;
|
61
|
+
frag_normal = in_normal;
|
62
|
+
|
63
|
+
if (ubo_renderable.use_per_vertex_color == 0) {
|
64
|
+
selected_color = vec4(ubo_renderable.color, 1.0);
|
65
|
+
} else {
|
66
|
+
selected_color = in_color;
|
67
|
+
}
|
68
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
struct SceneUBO {
|
4
|
+
vec3 camera_pos;
|
5
|
+
mat4 view;
|
6
|
+
mat4 projection;
|
7
|
+
vec3 ambient_light;
|
8
|
+
int point_light_count;
|
9
|
+
};
|
10
|
+
|
11
|
+
layout(binding = 0) uniform UBORenderable {
|
12
|
+
vec3 color;
|
13
|
+
int use_per_vertex_color;
|
14
|
+
int use_per_vertex_radius;
|
15
|
+
float radius;
|
16
|
+
}
|
17
|
+
ubo_renderable;
|
18
|
+
|
19
|
+
layout(binding = 1) uniform UBOScene {
|
20
|
+
SceneUBO scene;
|
21
|
+
float window_width;
|
22
|
+
float window_height;
|
23
|
+
float tan_half_fov;
|
24
|
+
float aspect_ratio;
|
25
|
+
}
|
26
|
+
ubo_scene;
|
27
|
+
|
28
|
+
struct PointLight {
|
29
|
+
vec3 pos;
|
30
|
+
vec3 color;
|
31
|
+
};
|
32
|
+
|
33
|
+
layout(binding = 2, std430) buffer SSBO {
|
34
|
+
PointLight point_lights[];
|
35
|
+
}
|
36
|
+
ssbo;
|
37
|
+
|
38
|
+
layout(location = 0) out vec4 out_color;
|
39
|
+
|
40
|
+
layout(location = 0) in vec4 pos_camera_space;
|
41
|
+
layout(location = 1) in vec4 selected_color;
|
42
|
+
layout(location = 2) in vec2 pos_2d;
|
43
|
+
layout(location = 3) in float selected_radius;
|
44
|
+
|
45
|
+
float project_z(float view_z) {
|
46
|
+
vec4 projected = ubo_scene.scene.projection * vec4(0, 0, view_z, 1);
|
47
|
+
return projected.z / projected.w;
|
48
|
+
}
|
49
|
+
|
50
|
+
vec3 to_camera_space(vec3 pos) {
|
51
|
+
vec4 temp = ubo_scene.scene.view * vec4(pos, 1.0);
|
52
|
+
return temp.xyz / temp.w;
|
53
|
+
}
|
54
|
+
|
55
|
+
// operates in camera space !!
|
56
|
+
vec3 lambertian(vec3 frag_pos, vec3 frag_normal) {
|
57
|
+
vec3 ambient = ubo_scene.scene.ambient_light * selected_color.rgb;
|
58
|
+
vec3 result = ambient;
|
59
|
+
|
60
|
+
for (int i = 0; i < ubo_scene.scene.point_light_count; ++i) {
|
61
|
+
vec3 light_color = ssbo.point_lights[i].color;
|
62
|
+
|
63
|
+
vec3 light_dir =
|
64
|
+
normalize(to_camera_space(ssbo.point_lights[i].pos) - frag_pos);
|
65
|
+
vec3 normal = normalize(frag_normal);
|
66
|
+
vec3 diffuse =
|
67
|
+
max(dot(light_dir, normal), 0.0) * selected_color.rgb * light_color;
|
68
|
+
|
69
|
+
result += diffuse;
|
70
|
+
}
|
71
|
+
|
72
|
+
return result;
|
73
|
+
}
|
74
|
+
|
75
|
+
void main() {
|
76
|
+
vec2 coord2D = pos_2d;
|
77
|
+
|
78
|
+
if (length(coord2D) >= 1.0) {
|
79
|
+
discard;
|
80
|
+
}
|
81
|
+
|
82
|
+
float z_in_sphere = sqrt(1 - coord2D.x * coord2D.x - coord2D.y * coord2D.y);
|
83
|
+
vec3 coord_in_sphere = vec3(coord2D, z_in_sphere);
|
84
|
+
|
85
|
+
vec3 frag_pos =
|
86
|
+
pos_camera_space.xyz / pos_camera_space.w + coord_in_sphere * selected_radius;
|
87
|
+
vec3 frag_normal = coord_in_sphere;
|
88
|
+
vec3 color = lambertian(frag_pos, frag_normal);
|
89
|
+
out_color = vec4(color, selected_color.a);
|
90
|
+
|
91
|
+
float depth =
|
92
|
+
(pos_camera_space.z / pos_camera_space.w) + z_in_sphere * selected_radius;
|
93
|
+
|
94
|
+
gl_FragDepth = project_z(depth);
|
95
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#version 450
|
2
|
+
#extension GL_KHR_vulkan_glsl : enable
|
3
|
+
|
4
|
+
layout(location = 0) in vec3 in_position;
|
5
|
+
layout(location = 1) in vec3 in_normal;
|
6
|
+
layout(location = 2) in vec2 in_texcoord;
|
7
|
+
layout(location = 3) in vec4 in_color;
|
8
|
+
|
9
|
+
struct SceneUBO {
|
10
|
+
vec3 camera_pos;
|
11
|
+
mat4 view;
|
12
|
+
mat4 projection;
|
13
|
+
vec3 ambient_light;
|
14
|
+
int point_light_count;
|
15
|
+
};
|
16
|
+
|
17
|
+
layout(binding = 0) uniform UBORenderable {
|
18
|
+
vec3 color;
|
19
|
+
int use_per_vertex_color;
|
20
|
+
int use_per_vertex_radius;
|
21
|
+
float radius;
|
22
|
+
}
|
23
|
+
ubo_renderable;
|
24
|
+
|
25
|
+
layout(binding = 1) uniform UBOScene {
|
26
|
+
SceneUBO scene;
|
27
|
+
float window_width;
|
28
|
+
float window_height;
|
29
|
+
float tan_half_fov;
|
30
|
+
float aspect_ratio;
|
31
|
+
}
|
32
|
+
ubo_scene;
|
33
|
+
layout(location = 0) out vec4 pos_camera_space;
|
34
|
+
layout(location = 1) out vec4 selected_color;
|
35
|
+
layout(location = 2) out vec2 pos_2d;
|
36
|
+
layout(location = 3) out float selected_radius;
|
37
|
+
|
38
|
+
const vec2 offsets[6] = {
|
39
|
+
vec2(-1.0f, 1.0f),
|
40
|
+
vec2(1.0f, -1.0f),
|
41
|
+
vec2(-1.0f, -1.0f),
|
42
|
+
vec2(-1.0f, 1.0f),
|
43
|
+
vec2(1.0f, 1.0f),
|
44
|
+
vec2(1.0f, -1.0f),
|
45
|
+
};
|
46
|
+
|
47
|
+
void main() {
|
48
|
+
float distance = length(in_position - ubo_scene.scene.camera_pos);
|
49
|
+
|
50
|
+
if (ubo_renderable.use_per_vertex_radius == 0) {
|
51
|
+
selected_radius = ubo_renderable.radius;
|
52
|
+
} else {
|
53
|
+
selected_radius = in_normal.x;
|
54
|
+
}
|
55
|
+
|
56
|
+
float hsize = selected_radius / (ubo_scene.tan_half_fov * distance);
|
57
|
+
|
58
|
+
pos_camera_space = ubo_scene.scene.view * vec4(in_position, 1.0);
|
59
|
+
|
60
|
+
pos_2d = offsets[gl_VertexIndex % 6];
|
61
|
+
|
62
|
+
vec4 pos_proj = ubo_scene.scene.projection * pos_camera_space;
|
63
|
+
pos_proj.xy += pos_2d * vec2(hsize, hsize * ubo_scene.window_width / ubo_scene.window_height) * pos_proj.w;
|
64
|
+
|
65
|
+
gl_Position = pos_proj;
|
66
|
+
gl_Position.y *= -1.0;
|
67
|
+
|
68
|
+
if (ubo_renderable.use_per_vertex_color == 0) {
|
69
|
+
selected_color = vec4(ubo_renderable.color, 1.0);
|
70
|
+
} else {
|
71
|
+
selected_color = in_color;
|
72
|
+
}
|
73
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(location = 0) in vec4 in_position;
|
4
|
+
layout(location = 1) in vec4 in_color;
|
5
|
+
|
6
|
+
layout(location = 0) out vec3 frag_color;
|
7
|
+
|
8
|
+
void main() {
|
9
|
+
gl_Position = in_position;
|
10
|
+
gl_Position.y = -gl_Position.y;
|
11
|
+
frag_color = in_color.rgb;
|
12
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(binding = 0) uniform sampler2D texSampler;
|
4
|
+
|
5
|
+
layout(location = 0) in vec2 frag_texcoord;
|
6
|
+
|
7
|
+
layout(location = 0) out vec4 out_color;
|
8
|
+
|
9
|
+
layout(binding = 1) uniform UBO {
|
10
|
+
vec2 lower_bound;
|
11
|
+
vec2 upper_bound;
|
12
|
+
float x_factor;
|
13
|
+
float y_factor;
|
14
|
+
int is_transposed;
|
15
|
+
} ubo;
|
16
|
+
|
17
|
+
void main() {
|
18
|
+
vec2 coord = frag_texcoord * vec2(ubo.x_factor,ubo.y_factor);
|
19
|
+
coord = clamp(coord, ubo.lower_bound, ubo.upper_bound);
|
20
|
+
out_color = textureLod(texSampler, ubo.is_transposed != 0 ? coord.yx : coord, 0);
|
21
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
// layout(binding = 0) uniform UniformBufferObject {} ubo;
|
4
|
+
|
5
|
+
layout(location = 0) in vec3 in_position;
|
6
|
+
layout(location = 1) in vec3 in_normal;
|
7
|
+
layout(location = 2) in vec2 in_texcoord;
|
8
|
+
layout(location = 3) in vec4 in_color;
|
9
|
+
|
10
|
+
layout(location = 0) out vec2 frag_texcoord;
|
11
|
+
|
12
|
+
void main() {
|
13
|
+
gl_Position = vec4(in_position.xy, 0.0, 1.0);
|
14
|
+
frag_texcoord = in_texcoord;
|
15
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(location = 0) in vec2 frag_texcoord;
|
4
|
+
layout(location = 1) in vec3 selected_color;
|
5
|
+
|
6
|
+
layout(location = 0) out vec4 out_color;
|
7
|
+
|
8
|
+
layout(binding = 0) uniform UniformBufferObject {
|
9
|
+
vec3 color;
|
10
|
+
int use_per_vertex_color;
|
11
|
+
}
|
12
|
+
ubo;
|
13
|
+
|
14
|
+
void main() {
|
15
|
+
out_color = vec4(selected_color, 1);
|
16
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#version 450
|
2
|
+
|
3
|
+
layout(location = 0) in vec3 in_position;
|
4
|
+
layout(location = 1) in vec3 in_normal;
|
5
|
+
layout(location = 2) in vec2 in_texcoord;
|
6
|
+
layout(location = 3) in vec4 in_color;
|
7
|
+
|
8
|
+
layout(location = 0) out vec2 frag_texcoord;
|
9
|
+
layout(location = 1) out vec3 selected_color;
|
10
|
+
|
11
|
+
layout(binding = 0) uniform UniformBufferObject {
|
12
|
+
vec3 color;
|
13
|
+
int use_per_vertex_color;
|
14
|
+
}
|
15
|
+
ubo;
|
16
|
+
|
17
|
+
void main() {
|
18
|
+
float x = in_position.x * 2.0 - 1.0;
|
19
|
+
float y = -(in_position.y * 2.0 - 1.0);
|
20
|
+
|
21
|
+
gl_Position = vec4(x, y, 0.0, 1.0);
|
22
|
+
frag_texcoord = in_texcoord;
|
23
|
+
|
24
|
+
if (ubo.use_per_vertex_color == 0) {
|
25
|
+
selected_color = ubo.color;
|
26
|
+
} else {
|
27
|
+
selected_color = in_color.rgb;
|
28
|
+
}
|
29
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# type: ignore
|
2
|
+
|
3
|
+
from taichi.lang.impl import grouped, root, static
|
4
|
+
from taichi.lang.kernel_impl import kernel
|
5
|
+
from taichi.lang.misc import ij, ijk
|
6
|
+
from taichi.lang.snode import is_active
|
7
|
+
from taichi.lang.struct import Struct
|
8
|
+
from taichi.types.annotations import template
|
9
|
+
from taichi.types.primitive_types import f32
|
10
|
+
|
11
|
+
|
12
|
+
def grid(field_dict, shape):
|
13
|
+
"""Creates a 2D/3D sparse grid with each element is a struct. The struct is placed on a bitmasked snode.
|
14
|
+
|
15
|
+
Args:
|
16
|
+
field_dict (dict): a dict, each item is like `name: type`.
|
17
|
+
shape (Tuple[int]): shape of the field.
|
18
|
+
Returns:
|
19
|
+
x: the created sparse grid, which is a bitmasked `ti.Struct.field`.
|
20
|
+
|
21
|
+
Examples::
|
22
|
+
# create a 2D sparse grid
|
23
|
+
>>> grid = ti.sparse.grid({'pos': ti.math.vec2, 'mass': ti.f32, 'grid2particles': ti.types.vector(20, ti.i32)}, shape=(10, 10))
|
24
|
+
|
25
|
+
# access
|
26
|
+
>>> grid[0, 0].pos = ti.math.vec2(1.0, 2.0)
|
27
|
+
>>> grid[0, 0].mass = 1.0
|
28
|
+
>>> grid[0, 0].grid2particles[2] = 123
|
29
|
+
|
30
|
+
# print the usage of the sparse grid, which is in [0,1]
|
31
|
+
>>> print(ti.sparse.usage(grid))
|
32
|
+
# 0.009999999776482582
|
33
|
+
"""
|
34
|
+
x = Struct.field(field_dict)
|
35
|
+
if len(shape) == 2:
|
36
|
+
snode = root.bitmasked(ij, shape)
|
37
|
+
snode.place(x)
|
38
|
+
elif len(shape) == 3:
|
39
|
+
snode = root.bitmasked(ijk, shape)
|
40
|
+
snode.place(x)
|
41
|
+
else:
|
42
|
+
raise Exception("Only 2D and 3D sparse grids are supported")
|
43
|
+
return x
|
44
|
+
|
45
|
+
|
46
|
+
@kernel
|
47
|
+
def usage(x: template()) -> f32:
|
48
|
+
"""
|
49
|
+
Get the usage of the sparse grid, which is in [0,1]
|
50
|
+
|
51
|
+
Args:
|
52
|
+
x(struct field): the sparse grid to be checked.
|
53
|
+
Returns:
|
54
|
+
usage(f32): the usage of the sparse grid, which is in [0,1]
|
55
|
+
|
56
|
+
Examples::
|
57
|
+
>>> grid = ti.sparse.grid({'pos': ti.math.vec2, 'mass': ti.f32, 'grid2particles': ti.types.vector(20, ti.i32)}, shape=(10, 10))
|
58
|
+
>>> grid[0, 0].mass = 1.0
|
59
|
+
>>> print(ti.sparse.usage(grid))
|
60
|
+
# 0.009999999776482582
|
61
|
+
"""
|
62
|
+
cnt = 0
|
63
|
+
for I in grouped(x.parent()):
|
64
|
+
if is_active(x.parent(), I):
|
65
|
+
cnt += 1
|
66
|
+
total = 1.0
|
67
|
+
if static(len(x.shape) == 2):
|
68
|
+
total = x.shape[0] * x.shape[1]
|
69
|
+
elif static(len(x.shape) == 3):
|
70
|
+
total = x.shape[0] * x.shape[1] * x.shape[2]
|
71
|
+
else:
|
72
|
+
raise ValueError("The dimension of the sparse grid should be 2 or 3")
|
73
|
+
res = cnt / total
|
74
|
+
return res
|
75
|
+
|
76
|
+
|
77
|
+
__all__ = ["grid", "usage"]
|
taichi/tools/__init__.py
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# type: ignore
|
2
|
+
|
3
|
+
"""Taichi utility module.
|
4
|
+
|
5
|
+
- `image` submodule for image io.
|
6
|
+
- `video` submodule for exporting results to video files.
|
7
|
+
- `diagnose` submodule for printing system environment information.
|
8
|
+
"""
|
9
|
+
|
10
|
+
from taichi.tools.diagnose import *
|
11
|
+
from taichi.tools.np2ply import *
|
12
|
+
from taichi.tools.vtk import *
|