From 91675826ea4fa075bed69833591299d5052128b8 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 17:57:26 +0800 Subject: [PATCH 01/15] [example] Add order-independent transparency example --- .../taichi/examples/rendering/oit_renderer.py | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 python/taichi/examples/rendering/oit_renderer.py diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py new file mode 100644 index 0000000000000..bd4e120a1bded --- /dev/null +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -0,0 +1,150 @@ +import taichi as ti + +from taichi.math import vec3, vec4, mix, clamp + +ti.init(arch=ti.gpu) +res = (1000, 1000) +color_buffer = ti.Vector.field(3, dtype=ti.f32, shape=res) + +eps = 1e-4 +inf = 1e10 +fov = 0.6 + +alpha_min = 0.2 +alpha_width = 0.5 +camera_pos = vec3(0, 0, 5) + +Hit = ti.types.struct(pos=vec3, normal=vec3, color=vec4, depth=float) +Sphere = ti.types.struct(center=vec3, radius=float, color=vec4) +ColorWithDepth = ti.types.struct(color=vec4, depth=float) +Light = ti.types.struct(pos=vec3, dir=vec3) + +background_color = vec4(0.2, 0.2, 0.2, 1) + +spheres = Sphere.field() +ti.root.dynamic(ti.j, 1024, chunk_size=64).place(spheres) +colors_in_pixel = ColorWithDepth.field() +ti.root.dense(ti.ij, res).dynamic(ti.k, 2048, chunk_size=64).place(colors_in_pixel) + + +@ti.func +def gooch_lighting(normal: ti.template()): + light = vec3(-1, 2, 1).normalized() + warmth = normal.normalized() * light * 0.5 + 0.5 + return mix(vec3(0, 0.25, 0.75), vec3(1, 1, 1), warmth) + + +@ti.func +def shading(hit: ti.template()): + colorRGB = hit.color.rgb * gooch_lighting(hit.normal) + alpha = clamp(alpha_min + hit.color.a * alpha_width, 0, 1) + return vec4(colorRGB, alpha) + + +@ti.func +def intersect_sphere(light: ti.template(), sphere: ti.template()): + hit_pos1 = vec3(0) + hit_pos2 = vec3(0) + normal1 = vec3(0) + normal2 = vec3(0) + dist1 = inf + dist2 = inf + l = sphere.center - light.pos + l2 = l.dot(l) + r2 = sphere.radius * sphere.radius + tp = l.dot(light.dir) + out_of_sphere = (l2 > r2) + may_have_intersection = True + if -eps < l2 - r2 < eps: + if -eps < tp < eps: + may_have_intersection = False + out_of_sphere = tp < 0 + if tp < 0 and out_of_sphere: + may_have_intersection = False + if may_have_intersection: + d2 = l2 - tp * tp + if d2 <= r2: + tt = ti.sqrt(r2 - d2) + t1 = tp - tt + if t1 > 0: + hit_pos1 = light.pos + light.dir * t1 + dist1 = t1 + normal1 = (hit_pos1 - sphere.center).normalized() + t2 = tp + tt + if t2 > 0: + hit_pos2 = light.pos + light.dir * t2 + dist2 = t2 + normal2 = (hit_pos2 - sphere.center).normalized() + return Hit(pos=hit_pos1, normal=normal1, color=sphere.color, depth=dist1), \ + Hit(pos=hit_pos2, normal=normal2, color=sphere.color, depth=dist2) + + +@ti.func +def get_intersections(u, v, light: ti.template()): + colors_in_pixel[u, v].deactivate() + for i in range(spheres.length()): + hit1, hit2 = intersect_sphere(light, spheres[i]) + if hit1.depth < inf: + colors_in_pixel[u, v].append(ColorWithDepth(color=shading(hit1), depth=hit1.depth)) + if hit2.depth < inf: + colors_in_pixel[u, v].append(ColorWithDepth(color=shading(hit2), depth=hit2.depth)) + + +@ti.func +def bubble_sort(u, v): + l = colors_in_pixel[u, v].length() + for i in range(l - 1): + for j in range(l - 1 - i): + if colors_in_pixel[u, v, j].depth > colors_in_pixel[u, v, j + 1].depth: + tmp = colors_in_pixel[u, v, j] + colors_in_pixel[u, v, j] = colors_in_pixel[u, v, j + 1] + colors_in_pixel[u, v, j + 1] = tmp + + +@ti.func +def blend(color: ti.template(), base_color: ti.template()): + color.rgb += (1 - color.a) * base_color.rgb * base_color.a + color.a += (1 - color.a) * base_color.a + + +@ti.func +def get_color(u, v): + bubble_sort(u, v) + color = vec4(0) + for i in range(colors_in_pixel[u, v].length()): + blend(color, colors_in_pixel[u, v, i].color) + blend(color, background_color) + return color + + +@ti.kernel +def render(): + for i in range(256): + spheres.append( + Sphere(vec3(ti.random() * 4 - 2, ti.random() * 4 - 2, ti.random() * 3 - 1.5), ti.random() * 0.3 + 0.1, + (ti.random(), ti.random(), ti.random(), ti.random() * 0.3 + 0.2))) + + for u, v in color_buffer: + aspect_ratio = res[0] / res[1] + pos = camera_pos + ray_dir = ti.Vector([ + (2 * fov * u / res[1] - fov * aspect_ratio - 1e-5), + (2 * fov * v / res[1] - fov - 1e-5), + -1.0, + ]) + ray_dir = ray_dir.normalized() + get_intersections(u, v, Light(pos=camera_pos, dir=ray_dir)) + color = get_color(u, v) + color_buffer[u, v] = ti.pow(color.rgb * color.a, 1 / 2.2) + + +def main(): + gui = ti.GUI('OIT', res, fast_gui=True) + render() + gui.set_image(color_buffer) + while gui.running: + gui.show() + + +if __name__ == '__main__': + main() From 2c402396e1d2ec1e3902e24b591bf6c2685888b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 10:04:39 +0000 Subject: [PATCH 02/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../taichi/examples/rendering/oit_renderer.py | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index bd4e120a1bded..d814386122d7d 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -1,6 +1,5 @@ import taichi as ti - -from taichi.math import vec3, vec4, mix, clamp +from taichi.math import clamp, mix, vec3, vec4 ti.init(arch=ti.gpu) res = (1000, 1000) @@ -24,7 +23,8 @@ spheres = Sphere.field() ti.root.dynamic(ti.j, 1024, chunk_size=64).place(spheres) colors_in_pixel = ColorWithDepth.field() -ti.root.dense(ti.ij, res).dynamic(ti.k, 2048, chunk_size=64).place(colors_in_pixel) +ti.root.dense(ti.ij, res).dynamic(ti.k, 2048, + chunk_size=64).place(colors_in_pixel) @ti.func @@ -85,9 +85,11 @@ def get_intersections(u, v, light: ti.template()): for i in range(spheres.length()): hit1, hit2 = intersect_sphere(light, spheres[i]) if hit1.depth < inf: - colors_in_pixel[u, v].append(ColorWithDepth(color=shading(hit1), depth=hit1.depth)) + colors_in_pixel[u, v].append( + ColorWithDepth(color=shading(hit1), depth=hit1.depth)) if hit2.depth < inf: - colors_in_pixel[u, v].append(ColorWithDepth(color=shading(hit2), depth=hit2.depth)) + colors_in_pixel[u, v].append( + ColorWithDepth(color=shading(hit2), depth=hit2.depth)) @ti.func @@ -95,7 +97,8 @@ def bubble_sort(u, v): l = colors_in_pixel[u, v].length() for i in range(l - 1): for j in range(l - 1 - i): - if colors_in_pixel[u, v, j].depth > colors_in_pixel[u, v, j + 1].depth: + if colors_in_pixel[u, v, j].depth > colors_in_pixel[u, v, + j + 1].depth: tmp = colors_in_pixel[u, v, j] colors_in_pixel[u, v, j] = colors_in_pixel[u, v, j + 1] colors_in_pixel[u, v, j + 1] = tmp @@ -121,8 +124,13 @@ def get_color(u, v): def render(): for i in range(256): spheres.append( - Sphere(vec3(ti.random() * 4 - 2, ti.random() * 4 - 2, ti.random() * 3 - 1.5), ti.random() * 0.3 + 0.1, - (ti.random(), ti.random(), ti.random(), ti.random() * 0.3 + 0.2))) + Sphere( + vec3(ti.random() * 4 - 2, + ti.random() * 4 - 2, + ti.random() * 3 - 1.5), + ti.random() * 0.3 + 0.1, + (ti.random(), ti.random(), ti.random(), + ti.random() * 0.3 + 0.2))) for u, v in color_buffer: aspect_ratio = res[0] / res[1] From ca431f56e6ad19b0e7163ff65bd95a5443b2ae49 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 18:48:38 +0800 Subject: [PATCH 03/15] ti.gpu -> ti.cuda --- python/taichi/examples/rendering/oit_renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index bd4e120a1bded..39199c2c49ea3 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -2,7 +2,7 @@ from taichi.math import vec3, vec4, mix, clamp -ti.init(arch=ti.gpu) +ti.init(arch=ti.cuda) res = (1000, 1000) color_buffer = ti.Vector.field(3, dtype=ti.f32, shape=res) From 20604c2a78d602f44e4705551089f66c3d41095a Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:08:10 +0800 Subject: [PATCH 04/15] lower fov --- python/taichi/examples/rendering/oit_renderer.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index caecd1cd5d458..bb79e95ab64d2 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -7,7 +7,8 @@ eps = 1e-4 inf = 1e10 -fov = 0.6 +fov = 0.5 +aspect_ratio = res[0] / res[1] alpha_min = 0.2 alpha_width = 0.5 @@ -125,16 +126,14 @@ def render(): for i in range(256): spheres.append( Sphere( - vec3(ti.random() * 4 - 2, - ti.random() * 4 - 2, + vec3(ti.random() * 3 - 1.5, + ti.random() * 3 - 1.5, ti.random() * 3 - 1.5), - ti.random() * 0.3 + 0.1, + ti.random() * 0.2 + 0.1, (ti.random(), ti.random(), ti.random(), ti.random() * 0.3 + 0.2))) for u, v in color_buffer: - aspect_ratio = res[0] / res[1] - pos = camera_pos ray_dir = ti.Vector([ (2 * fov * u / res[1] - fov * aspect_ratio - 1e-5), (2 * fov * v / res[1] - fov - 1e-5), From 4ac63a9979654c7427dd9c6ef03b2f5e412a24fc Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:30:21 +0800 Subject: [PATCH 05/15] simplify ray_dir --- python/taichi/examples/rendering/oit_renderer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index bb79e95ab64d2..281c663d80d00 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -120,6 +120,8 @@ def get_color(u, v): blend(color, background_color) return color +stratify_res = 5 +inv_stratify = 1.0 / stratify_res @ti.kernel def render(): @@ -135,9 +137,9 @@ def render(): for u, v in color_buffer: ray_dir = ti.Vector([ - (2 * fov * u / res[1] - fov * aspect_ratio - 1e-5), - (2 * fov * v / res[1] - fov - 1e-5), - -1.0, + (2 * (u + 0.5) / res[0] - 1) * aspect_ratio, + (2 * (v + 0.5) / res[1] - 1), + -1.0 / fov, ]) ray_dir = ray_dir.normalized() get_intersections(u, v, Light(pos=camera_pos, dir=ray_dir)) From e5e4afd099e24764aa7b97e5bfce7c46ff9486e3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:32:34 +0000 Subject: [PATCH 06/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- python/taichi/examples/rendering/oit_renderer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 281c663d80d00..7ac7fb96c758f 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -120,9 +120,11 @@ def get_color(u, v): blend(color, background_color) return color + stratify_res = 5 inv_stratify = 1.0 / stratify_res + @ti.kernel def render(): for i in range(256): From eb0a9b84deea70f7316ec1fb3642cc4d45e3fb7f Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:40:30 +0800 Subject: [PATCH 07/15] Apply suggestions from code review Co-authored-by: Zhao Liang --- python/taichi/examples/rendering/oit_renderer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 7ac7fb96c758f..114edb3903d71 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -1,5 +1,5 @@ import taichi as ti -from taichi.math import clamp, mix, vec3, vec4 +from taichi.math import clamp, mix, vec3, vec4, normalize ti.init(arch=ti.cuda) res = (1000, 1000) @@ -30,8 +30,8 @@ @ti.func def gooch_lighting(normal: ti.template()): - light = vec3(-1, 2, 1).normalized() - warmth = normal.normalized() * light * 0.5 + 0.5 + light = normalize(vec3(-1, 2, 1)) + warmth = normalize(normal) * light * 0.5 + 0.5 return mix(vec3(0, 0.25, 0.75), vec3(1, 1, 1), warmth) @@ -70,12 +70,12 @@ def intersect_sphere(light: ti.template(), sphere: ti.template()): if t1 > 0: hit_pos1 = light.pos + light.dir * t1 dist1 = t1 - normal1 = (hit_pos1 - sphere.center).normalized() + normal1 = normalize((hit_pos1 - sphere.center) t2 = tp + tt if t2 > 0: hit_pos2 = light.pos + light.dir * t2 dist2 = t2 - normal2 = (hit_pos2 - sphere.center).normalized() + normal2 = normalize(hit_pos2 - sphere.center) return Hit(pos=hit_pos1, normal=normal1, color=sphere.color, depth=dist1), \ Hit(pos=hit_pos2, normal=normal2, color=sphere.color, depth=dist2) @@ -143,7 +143,7 @@ def render(): (2 * (v + 0.5) / res[1] - 1), -1.0 / fov, ]) - ray_dir = ray_dir.normalized() + ray_dir = normalize(ray_dir) get_intersections(u, v, Light(pos=camera_pos, dir=ray_dir)) color = get_color(u, v) color_buffer[u, v] = ti.pow(color.rgb * color.a, 1 / 2.2) From e4126ac312414d58f73fac203cf242b1bfc5e152 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:42:38 +0800 Subject: [PATCH 08/15] fix --- python/taichi/examples/rendering/oit_renderer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 114edb3903d71..2eb7ac3f463c0 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -31,7 +31,7 @@ @ti.func def gooch_lighting(normal: ti.template()): light = normalize(vec3(-1, 2, 1)) - warmth = normalize(normal) * light * 0.5 + 0.5 + warmth = normal * light * 0.5 + 0.5 return mix(vec3(0, 0.25, 0.75), vec3(1, 1, 1), warmth) @@ -70,7 +70,7 @@ def intersect_sphere(light: ti.template(), sphere: ti.template()): if t1 > 0: hit_pos1 = light.pos + light.dir * t1 dist1 = t1 - normal1 = normalize((hit_pos1 - sphere.center) + normal1 = normalize(hit_pos1 - sphere.center) t2 = tp + tt if t2 > 0: hit_pos2 = light.pos + light.dir * t2 From a076435b764f83571ac1b225527904acb4fe082d Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:43:09 +0800 Subject: [PATCH 09/15] fix --- python/taichi/examples/rendering/oit_renderer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 2eb7ac3f463c0..4893007b9ca1f 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -138,11 +138,10 @@ def render(): ti.random() * 0.3 + 0.2))) for u, v in color_buffer: - ray_dir = ti.Vector([ + ray_dir = vec3( (2 * (u + 0.5) / res[0] - 1) * aspect_ratio, (2 * (v + 0.5) / res[1] - 1), - -1.0 / fov, - ]) + -1.0 / fov) ray_dir = normalize(ray_dir) get_intersections(u, v, Light(pos=camera_pos, dir=ray_dir)) color = get_color(u, v) From 0381f4a5bb936095b400264c304ae6478e21c9c7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:47:14 +0000 Subject: [PATCH 10/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- python/taichi/examples/rendering/oit_renderer.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 4893007b9ca1f..2d052e6a555bb 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -1,5 +1,5 @@ import taichi as ti -from taichi.math import clamp, mix, vec3, vec4, normalize +from taichi.math import clamp, mix, normalize, vec3, vec4 ti.init(arch=ti.cuda) res = (1000, 1000) @@ -138,10 +138,8 @@ def render(): ti.random() * 0.3 + 0.2))) for u, v in color_buffer: - ray_dir = vec3( - (2 * (u + 0.5) / res[0] - 1) * aspect_ratio, - (2 * (v + 0.5) / res[1] - 1), - -1.0 / fov) + ray_dir = vec3((2 * (u + 0.5) / res[0] - 1) * aspect_ratio, + (2 * (v + 0.5) / res[1] - 1), -1.0 / fov) ray_dir = normalize(ray_dir) get_intersections(u, v, Light(pos=camera_pos, dir=ray_dir)) color = get_color(u, v) From f1a3737db3a19d072e3b6fea8779d6962d849828 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:50:52 +0800 Subject: [PATCH 11/15] fix --- python/taichi/examples/rendering/oit_renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 4893007b9ca1f..59e1d8a379989 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -135,7 +135,7 @@ def render(): ti.random() * 3 - 1.5), ti.random() * 0.2 + 0.1, (ti.random(), ti.random(), ti.random(), - ti.random() * 0.3 + 0.2))) + ti.random()))) for u, v in color_buffer: ray_dir = vec3( From bbdb97d258b2509a7ff8fab53f74399983cc97e2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:53:09 +0000 Subject: [PATCH 12/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- python/taichi/examples/rendering/oit_renderer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 63fdd1e464ad2..c5f230662dbe6 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -134,8 +134,7 @@ def render(): ti.random() * 3 - 1.5, ti.random() * 3 - 1.5), ti.random() * 0.2 + 0.1, - (ti.random(), ti.random(), ti.random(), - ti.random()))) + (ti.random(), ti.random(), ti.random(), ti.random()))) for u, v in color_buffer: ray_dir = vec3((2 * (u + 0.5) / res[0] - 1) * aspect_ratio, From 5fad2a6da4f9e218b57664484a05cc09317983d9 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:56:35 +0800 Subject: [PATCH 13/15] fix --- python/taichi/examples/rendering/oit_renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index 63fdd1e464ad2..2dff3bafd4a68 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -11,7 +11,7 @@ aspect_ratio = res[0] / res[1] alpha_min = 0.2 -alpha_width = 0.5 +alpha_width = 0.3 camera_pos = vec3(0, 0, 5) Hit = ti.types.struct(pos=vec3, normal=vec3, color=vec4, depth=float) From d5cb8c95996288314a8617ed23c3915a33512997 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Wed, 7 Dec 2022 19:59:27 +0800 Subject: [PATCH 14/15] Update oit_renderer.py --- python/taichi/examples/rendering/oit_renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index c5f230662dbe6..e1026951d9625 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -11,7 +11,7 @@ aspect_ratio = res[0] / res[1] alpha_min = 0.2 -alpha_width = 0.5 +alpha_width = 0.3 camera_pos = vec3(0, 0, 5) Hit = ti.types.struct(pos=vec3, normal=vec3, color=vec4, depth=float) From ad96ea475390797739e733d4009a917d48034cc5 Mon Sep 17 00:00:00 2001 From: Lin Jiang Date: Thu, 8 Dec 2022 11:04:02 +0800 Subject: [PATCH 15/15] add comments --- python/taichi/examples/rendering/oit_renderer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/taichi/examples/rendering/oit_renderer.py b/python/taichi/examples/rendering/oit_renderer.py index e1026951d9625..efe7a960e0cd5 100644 --- a/python/taichi/examples/rendering/oit_renderer.py +++ b/python/taichi/examples/rendering/oit_renderer.py @@ -1,3 +1,5 @@ +# A demo of order-independent transparency using Taichi +# Reference: https://github.com/nvpro-samples/vk_order_independent_transparency import taichi as ti from taichi.math import clamp, mix, normalize, vec3, vec4