-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] [example] Add test and video generator for cornell box. (#4045)
- Loading branch information
Showing
2 changed files
with
63 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import argparse | ||
|
||
import taichi as ti | ||
|
||
FRAMES = 200 | ||
|
||
|
||
def test_cornell_box(): | ||
from taichi.examples.rendering.cornell_box import render, tonemap | ||
for i in range(FRAMES): | ||
render() | ||
interval = 10 | ||
if i % interval == 0: | ||
tonemap(i) | ||
|
||
|
||
def video_cornell_box(result_dir): | ||
from taichi.examples.rendering.cornell_box import (render, tonemap, | ||
tonemapped_buffer) | ||
video_manager = ti.VideoManager(output_dir=result_dir, | ||
framerate=24, | ||
automatic_build=False) | ||
gui = ti.GUI("Taichi Cornell Box", | ||
res=800, | ||
background_color=0x112F41, | ||
show_gui=False) | ||
for i in range(FRAMES): | ||
render() | ||
interval = 10 | ||
if i % interval == 0: | ||
tonemap(i) | ||
|
||
gui.set_image(tonemapped_buffer) | ||
video_manager.write_frame(gui.get_image()) | ||
gui.clear() | ||
video_manager.make_video(mp4=True, gif=False) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Generate cornell_box video') | ||
parser.add_argument('output_directory', | ||
help='output directory of generated video') | ||
video_cornell_box(parser.parse_args().output_directory) |
3b5b3ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: