From b66c108e12c44ef77f9177df695f1a02b6b34638 Mon Sep 17 00:00:00 2001 From: Manolis Savva Date: Mon, 10 Sep 2018 10:21:57 +0200 Subject: [PATCH] fixes to AO settings and camera loading for SUNCG json files --- client/js/lib/gfx/Renderer.js | 10 +++++----- client/js/lib/scene/SUNCGLoader.js | 3 ++- ssc/config/render_suncg.json | 1 + ssc/render-file.js | 11 +++++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/client/js/lib/gfx/Renderer.js b/client/js/lib/gfx/Renderer.js index 75ca92a..859ce7e 100644 --- a/client/js/lib/gfx/Renderer.js +++ b/client/js/lib/gfx/Renderer.js @@ -20,7 +20,7 @@ define(['Constants','util/ImageUtil','geo/Object3DUtil','three-shaders', 'gfx/ED this.outlineColor = (opt.outlineColor !== undefined) ? opt.outlineColor : 0xffffff; this.ambientOcclusionOptions = _.merge({ type: opt.ambientOcclusionType || 'ssao' - }, this.ambientOcclusionOptions); + }, opt.ambientOcclusionOptions); this.useShadows = (opt.useShadows !== undefined) ? opt.useShadows : false; this.useLights = (opt.useLights !== undefined) ? opt.useLights : false; // Default to false this.__reuseBuffers = opt.reuseBuffers; // Reuse buffers? @@ -88,15 +88,15 @@ define(['Constants','util/ImageUtil','geo/Object3DUtil','three-shaders', 'gfx/ED var ssao = null; if (this.ambientOcclusionOptions.type === 'ssao') { ssao = new THREE.SSAOPass(scene, camera /*, this.width, this.height*/); - ssao.radius = this.ambientOcclusionOptions.radius || (0.5*Constants.virtualUnitToMeters); - console.log('set ssao.radius to ', ssao.radius); - ssao.lumInfluence = 0.1; + ssao.radius = this.ambientOcclusionOptions.radius || (0.1*Constants.virtualUnitToMeters); + ssao.lumInfluence = (this.ambientOcclusionOptions.lumInfluence != undefined)? this.ambientOcclusionOptions.lumInfluence : 0.5; + console.log('set ssao.radius to', ssao.radius, 'ssao.lumInfluence to', ssao.lumInfluence); } else if (this.ambientOcclusionOptions.type === 'sao') { ssao = new THREE.SAOPass(scene, camera, false, true); ssao.params.saoScale = this.ambientOcclusionOptions.scale || 20000; // TODO(MS): set this parameter more intelligently // ssao.params.saoScaleFixed = 0.03; // ssao.params.saoScale = ssao.params.saoScaleFixed*camera.far; // TODO(MS): set this parameter more intelligently - //console.log('set sao.params.soaScale to ', ssao.params.saoScale, camera.far ); + console.log('set sao.params.soaScale to', ssao.params.saoScale, 'with camera far', camera.far ); } else { console.warn('Unsupported ambientOcclusion configuration', this.ambientOcclusionOptions) } diff --git a/client/js/lib/scene/SUNCGLoader.js b/client/js/lib/scene/SUNCGLoader.js index 0a98cc7..dc129a7 100644 --- a/client/js/lib/scene/SUNCGLoader.js +++ b/client/js/lib/scene/SUNCGLoader.js @@ -256,7 +256,7 @@ SUNCGLoader.prototype.parse = function (json, callback, url, loadOpts) { SUNCGLoader.prototype.__parseCamera = function(cameraJson, sceneResult) { var cameras; if (_.isArray(cameraJson)) { - cameras = _.groupBy(cameraJson, 'name'); + cameras = _.keyBy(cameraJson, 'name'); } else { cameras = cameraJson; } @@ -587,6 +587,7 @@ SUNCGLoader.prototype.__parseBox = function (json, context, callback) { var scope = this; var parsed = { json: json, parent: context.parent, floor: context.floor, id: context.id, index: context.index }; + // See SUNCG house.json for 93cdd63ea3523de8fb5d56ac5dc1b7e4 var dims = json.dimensions; var box = new THREE.BoxGeometry(dims[0], dims[1], dims[2], 1, 1, 1); for (var i = 0; i < box.faceVertexUvs.length; i++) { diff --git a/ssc/config/render_suncg.json b/ssc/config/render_suncg.json index 65623d6..376b4b8 100644 --- a/ssc/config/render_suncg.json +++ b/ssc/config/render_suncg.json @@ -13,6 +13,7 @@ "assetType": "scene", "includeCeiling": false, "useArchModelId": true, + "ignoreOriginalArchHoles": false, "attachWallsToRoom": false, "createArch": true } diff --git a/ssc/render-file.js b/ssc/render-file.js index 12c63ad..9c77fc1 100755 --- a/ssc/render-file.js +++ b/ssc/render-file.js @@ -16,6 +16,7 @@ cmd .option('--assetType ', 'Asset type (scene or model)', 'model') .option('--output_dir ', 'Base directory for output files', '.') .option('--output ', 'Output path') + .option('--auto_align [flag]', 'Whether to auto align asset', STK.util.cmd.parseBoolean, false) .optionGroups(['config_file', 'render_options', 'view', 'render_views', 'color_by']) .option('--skip_existing', 'Skip rendering existing images [false]') .option('--material_type ') @@ -77,7 +78,7 @@ var renderer = new STK.PNGRenderer({ }); var useSearchController = cmd.use_search_controller; var assetManager = new STK.assets.AssetManager({ - autoAlignModels: false, autoScaleModels: false, assetCacheSize: 100, + autoAlignModels: cmd.auto_align, autoScaleModels: false, assetCacheSize: 100, searchController: useSearchController? new STK.search.BasicSearchController() : null }); @@ -182,7 +183,7 @@ function processFiles() { var basename = output_basename; if (basename) { // Specified output - append index - if (files.length > 0) { + if (files.length > 1) { basename = basename + '_' + index; } basename = outputDir? outputDir + '/' + basename : basename; @@ -210,8 +211,10 @@ function processFiles() { assetManager.loadAsset(info, function (err, asset) { var sceneState; + var defaultViewOpts = {}; if (asset instanceof STK.scene.SceneState) { sceneState = asset; + defaultViewOpts = { view_index: 0 }; } else if (asset instanceof STK.model.ModelInstance) { var modelInstance = asset; sceneState = new STK.scene.SceneState(null, modelInstance.model.info); @@ -221,7 +224,7 @@ function processFiles() { m.geometry = STK.geo.GeometryUtil.toGeometry(m.geometry); }); console.timeEnd('toGeometry'); - sceneState.addObject(modelInstance); + sceneState.addObject(modelInstance, cmd.auto_align); } else if (err) { console.error("Error loading asset", info, err); return; @@ -300,7 +303,7 @@ function processFiles() { var cmdOpts = _.defaults( _.pick(cmd, ['render_all_views', 'render_turntable', 'view', 'view_index', - 'width', 'height', 'max_width', 'max_height', 'max_pixels', 'save_view_log']), { view_index: 0} ); + 'width', 'height', 'max_width', 'max_height', 'max_pixels', 'save_view_log']), defaultViewOpts); if (cmdOpts.view && cmdOpts.view.coordinate_frame === 'scene') { cmdOpts.view = sceneState.convertCameraConfig(cmdOpts.view); }