This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy path11.instance_motion_blur.py
More file actions
executable file
·128 lines (103 loc) · 3.54 KB
/
Copy path11.instance_motion_blur.py
File metadata and controls
executable file
·128 lines (103 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import visii
opt = lambda: None
opt.spp = 100
opt.width = 1280
opt.height = 720
opt.noise = False
opt.path_obj = 'content/dragon/dragon.obj'
opt.out = '11_instance_motion_blur.png'
# # # # # # # # # # # # # # # # # # # # # # # # #
visii.initialize(headless=True, verbose=True)
if not opt.noise is True:
visii.enable_denoiser()
camera = visii.entity.create(
name = "camera",
transform = visii.transform.create("camera"),
camera = visii.camera.create(
name = "camera",
aspect = float(opt.width)/float(opt.height)
)
)
camera.get_transform().look_at(
at = (0,0.1,0.1),
up = (0,0,1),
eye = (0,3.0,0.2),
)
visii.set_camera_entity(camera)
visii.set_dome_light_sky(sun_position = (10, 10, 1), saturation = 2)
visii.set_dome_light_intensity(1.5)
# # # # # # # # # # # # # # # # # # # # # # # # #
floor = visii.entity.create(
name = "floor",
mesh = visii.mesh.create_plane("floor", size = (10,10)),
material = visii.material.create("floor", base_color = (.5, .5, .5), roughness = 0.0, metallic = 1.0),
transform = visii.transform.create("floor", position = (0,0,-.3))
)
# Next, let's load an obj
mesh = visii.mesh.create_from_file("obj", opt.path_obj)
# Now, lets make three instances of that mesh
obj1 = visii.entity.create(
name="obj1",
mesh = mesh,
transform = visii.transform.create("obj1"),
material = visii.material.create("obj1")
)
obj2 = visii.entity.create(
name="obj2",
mesh = mesh,
transform = visii.transform.create("obj2"),
material = visii.material.create("obj2")
)
obj3 = visii.entity.create(
name="obj3",
mesh = mesh,
transform = visii.transform.create("obj3"),
material = visii.material.create("obj3")
)
obj4 = visii.entity.create(
name="obj4",
mesh = mesh,
transform = visii.transform.create("obj4"),
material = visii.material.create("obj4")
)
# place those objects into the scene
# lets set the obj_entity up
obj1.get_transform().set_position((-1.5, 0, 0))
obj1.get_transform().set_rotation((0.7071, 0, 0, 0.7071))
obj1.get_material().set_base_color((1,0,0))
obj1.get_material().set_roughness(0.7)
obj1.get_material().set_specular(1)
obj1.get_material().set_sheen(1)
obj2.get_transform().set_position((-.5, 0, 0))
obj2.get_transform().set_rotation((0.7071, 0, 0, 0.7071))
obj2.get_material().set_base_color((0,1,0))
obj2.get_material().set_roughness(0.7)
obj2.get_material().set_specular(1)
obj2.get_material().set_sheen(1)
obj3.get_transform().set_position((.5, 0, 0))
obj3.get_transform().set_rotation((0.7071, 0, 0, 0.7071))
obj3.get_material().set_base_color((0,0,1))
obj3.get_material().set_roughness(0.7)
obj3.get_material().set_specular(1)
obj3.get_material().set_sheen(1)
obj4.get_transform().set_position((1.5, 0, 0))
obj4.get_transform().set_rotation((0.7071, 0, 0, 0.7071))
obj4.get_material().set_base_color((.5,.5,.5))
obj4.get_material().set_roughness(0.7)
obj4.get_material().set_specular(1)
obj4.get_material().set_sheen(1)
# Use linear motion blur on the first object...
obj1.get_transform().set_linear_velocity((.0, .0, .2))
# angular motion blur on the second object...
obj2.get_transform().set_angular_velocity((visii.pi() / 16, visii.pi() / 16, visii.pi() / 16, 1))
# and scalar motion blur on the third object
obj3.get_transform().set_scalar_velocity((-.5, -.5, -.5))
# # # # # # # # # # # # # # # # # # # # # # # # #
visii.render_to_png(
width=int(opt.width),
height=int(opt.height),
samples_per_pixel=int(opt.spp),
image_path=f"{opt.out}"
)
# let's clean up the GPU
visii.deinitialize()