Skip to content

Commit

Permalink
add support for v4(upgrade to v4 file, have bugs)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyskeys committed Oct 11, 2020
1 parent 177a26f commit 79ed4e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 12 additions & 3 deletions btop/render/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ def render(self, depsgraph):
pref = get_pref()
pbrt_executable = pref.pbrt_location
cache_folder = pref.pbrt_cache_folder
use_v4 = pref.pbrt_use_v4

# Setup output file name
# todo : decide output file type with an user option
filename = os.path.basename(bpy.data.filepath) or 'tmp.blend'
cache_filepath = os.path.join(cache_folder, filename.replace('.blend', '.pbrt'))
converted_cache_filepath = os.path.join(cache_folder, filename.replace('.blend', '_converted.pbrt'))
outfile = os.path.join(cache_folder, filename.replace('.blend', '.exr'))

# Get film resolution from camera attributes
Expand All @@ -60,9 +62,16 @@ def render(self, depsgraph):
exporter.export(cache_filepath)

try:
#subprocess.call([pbrt_executable, '--outfile', outfile, cache_filepath])
cmd_comps = [pbrt_executable, '--outfile', outfile, cache_filepath]
print('command is : ', ' '.join(cmd_comps))
cmd_comps = [pbrt_executable, '--outfile', outfile]
if use_v4:
convert_cmd_comps = [pbrt_executable, '--upgrade', cache_filepath, '>', converted_cache_filepath]
print('Convert command : ', ' '.join(convert_cmd_comps))
os.system(' '.join(convert_cmd_comps))
cmd_comps.append(converted_cache_filepath)
else:
cmd_comps.append(cache_filepath)

print('Render command : ', ' '.join(cmd_comps))
os.system(' '.join(cmd_comps))

# Load rendered picture and display it in the viewport
Expand Down
1 change: 0 additions & 1 deletion btop/ui/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def draw(self, context):
elif light.type == "AREA":
layout.row().prop(light_props, "twosided")
layout.row().prop(light_props, "samples")
#layout.prop_search(light, "area_light_geometry", bpy.data, "objects")
layout.row().prop(light_props, "geometry")


Expand Down
5 changes: 5 additions & 0 deletions btop/ui/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ class PBRTPreferences(bpy.types.AddonPreferences):
default=os.path.join(os.path.expanduser("~"), 'pbrt_scene'),
subtype='FILE_PATH')

pbrt_use_v4: bpy.props.BoolProperty(name="pbrt_use_v4",
description="Use version 4 pbrt binary",
default=False)

def draw(self, context):
layout = self.layout

layout.row().prop(self, 'pbrt_location', text="PBRT location")
layout.row().prop(self, 'pbrt_cache_folder', text="Cache Folder")
layout.row().prop(self, 'pbrt_use_v4', text="Use Version 4")


def get_pref():
Expand Down

0 comments on commit 79ed4e0

Please sign in to comment.