def cmd_shop(shop, shaderstring, shoptype = soho.ShopTypeDefault): # Declare an old style shader shader = soho.processShader(shaderstring, ForceEmbedVex, False, shoptype) if len(shader[1]): print shader[1] soho.indent() print 'cmd_shop', shop, shader[0]
def cmd_loadotl(otls, from_text_block=False): cmd = 'cmd_loadotl ' if from_text_block: cmd += '-t ' for l in otls: soho.indent() soho.printArray(cmd, [l], '\n')
def _api_dtype_call(directive, dtype, paramset=None): soho.indent() print(directive, ' "', dtype, '"', sep='', end='') if paramset: for param in paramset: print(' ', sep='', end='') param.print_str() print()
def cmd_textblock(name, value, encoding=None): soho.indent() if encoding: print 'cmd_textblock -e', encoding, name else: print 'cmd_textblock', name print value print 'cmd_endtext'
def cmd_reset(light=True, obj=True, fog=True): options = '' if light: options += ' -l' if obj: options += ' -o' if fog: options += ' -f' soho.indent(-1, 'cmd_reset %s' % options)
def cmd_propertyV(style, parmlist): if style: for parm in parmlist: soho.indent() parm.printValue('cmd_property %s %s ' % (style, parm.Key), '\n') else: for parm in parmlist: soho.indent() parm.printValue('cmd_property %s %s '%(parm.Style, parm.Key), '\n')
def cmd_shader(style, name, orgshader, shoptype = soho.ShopTypeDefault): # Processing the shader may generate VEX code or COP maps and # will return the value in the second element of the tuple. This # should be printed before the shader string. shader = soho.processShader(orgshader, ForceEmbedVex, False, shoptype) if len(shader[1]): print shader[1] soho.indent() print 'cmd_property', style, name, shader[0]
def cmd_bundle(bundle, node_paths): soho.indent() print 'cmd_bundlecreate', bundle soho.addBundleDependency(bundle) start = 0 step = 100 while len(node_paths) > start: end = start + step print 'cmd_bundleadd', bundle, " ".join(node_paths[start:end]) start = end
def cmd_makecubemap(path, suffixes): soho.indent() # When there are spaces in the path names, the quote protection for this # command can be incredibly difficult. sys.stdout.write('''python -c 'import os; os.system("isixpack''') for s in suffixes: sys.stdout.write(' \\"%s%s\\"' % (path, s)) sys.stdout.write(''' \\"%s\\"")'\n''' % path); for s in suffixes: soho.indent() sys.stdout.write('cmd_unlink -f "%s%s"\n' % ( path, s))
def cmd_image(filename, device="", options=""): soho.makeFilePathDirsIfEnabled(filename) args = [] if device: args.append("-f") args.append(device) if options: options = ' ' + options args.append(filename) istr = soho.arrayToString('cmd_image ', args, options) soho.indent(1, istr, None)
def _api_named_dtype_call(directive, name, output, dtype, paramset=None): soho.indent() print(directive, '"{name}" "{output}" "{dtype}"'.format(name=name, output=output, dtype=dtype), end='') if paramset: for param in paramset: print(' ', param.as_str(), sep='', end='') print()
def cmd_prefilter(path, prefilter_path, filter, count, ratio): soho.indent() # Create a temporary file in the same directory as the original map pathsplit = os.path.split(path) args = [ '"%s" prefilter' % path, 'photon_file "%s"' % path, 'prefiltered_file "%s"' % prefilter_path, 'count %d' % count, 'filter %s' % filter, 'ratio %f' % ratio ] filterargs = ' '.join(args) sys.stdout.write('cmd_pcfilter %s\n' % (filterargs))
def cmd_procedural(bounds, proc, shoptype = soho.ShopTypeDefault): soho.indent() shader = soho.processShader(proc[0], ForceEmbedVex, False, shoptype) if len(shader[1]): print shader[1] if bounds[0] <= bounds[3]: soho.printArray('cmd_procedural -m ', bounds[0:3], '') soho.printArray( ' -M ', bounds[3:6], ' '), else: sys.stdout.write('cmd_procedural ') sys.stdout.write(shader[0]) sys.stdout.write('\n') print
def WorldEnd(): soho.indent(-1, "WorldEnd", PBRT_COMMENT)
def Comment(msg): soho.indent() print("# ", msg)
def _api_call_with_cmds(directive, *args): soho.indent() print(directive, end='') soho.printArray(' ', args, '\n', False)
def _api_call_with_iter(directive, args): soho.indent() print(directive, end='') soho.printArray(' [ ', args, ' ]\n')
def WorldBegin(): soho.indent(1, 'WorldBegin', PBRT_COMMENT)
def WorldEnd(): soho.indent(-1, 'WorldEnd', PBRT_COMMENT)
def ObjectBegin(name): soho.indent(1, 'ObjectBegin "%s"' % name, PBRT_COMMENT)
def ObjectEnd(): soho.indent(-1, 'ObjectEnd', PBRT_COMMENT)
def AttributeBegin(): soho.indent(1, 'AttributeBegin', PBRT_COMMENT)
def AttributeEnd(): soho.indent(-1, 'AttributeEnd', PBRT_COMMENT)
def TransformEnd(): soho.indent(-1, 'TransformEnd', PBRT_COMMENT)
def TransformBegin(): soho.indent(1, 'TransformBegin', PBRT_COMMENT)
def _api_call_with_cmds(directive, *args): soho.indent() print(directive, end="") soho.printArray(" ", args, "\n", False)
def Comment(msg): soho.indent() print('# ', msg)
def _api_call_with_iter(directive, args): soho.indent() print(directive, end="") soho.printArray(" [ ", args, " ]\n")
def _api_call(directive): soho.indent() print(directive)
def render(cam, now): """Main render entry point""" start_time = time.time() # For now we will not be using wranglers wrangler = None header() for name, value in wrangle_options(cam, wrangler, now): api.Option(name, value) val = [] if cam.evalString("pbrt_colorspace", now, val): api.ColorSpace(val[0]) print() api.Film(*wrangle_film(cam, wrangler, now)) api.Filter(*wrangle_filter(cam, wrangler, now)) api.Sampler(*wrangle_sampler(cam, wrangler, now)) api.Integrator(*wrangle_integrator(cam, wrangler, now)) api.Accelerator(*wrangle_accelerator(cam, wrangler, now)) print() # We will stash the global exterior in case they need # to be compared against later. # Pre WorldBegin Mediums can't have AttributeBlocks and thus # need to be output relative to the camera's space. exterior = wrangle_preworld_medium(cam, wrangler, now) if exterior: api.MediumInterface("", exterior) print() # wrangle_camera will output api.Transforms api.Comment(cam.getName()) api.Camera(*wrangle_camera(cam, wrangler, now)) # Stash the camera's shutter as the default. scene_state.shutter = cam.wrangleFloat(wrangler, "shutter", now, [scene_state.shutter])[0] print() output_transform_times(cam, now) api.WorldBegin() print() # Output Lights api.Comment("=" * 50) api.Comment("Light Definitions") for light in soho.objectList("objlist:light"): api.Comment(light.getName()) with api.AttributeBlock(): val = [] if light.evalString("pbrt_colorspace", now, val): api.ColorSpace(val[0]) wrangle_light(light, wrangler, now) print() print() scene_renderables(now) print() # This was previously an api.WorldEnd() which would have provided the deindent soho.indent(-1) footer(start_time) return