Skip to content

Commit

Permalink
fixes to AO settings and camera loading for SUNCG json files
Browse files Browse the repository at this point in the history
  • Loading branch information
msavva committed Sep 10, 2018
1 parent 6e6f305 commit b66c108
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions client/js/lib/gfx/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion client/js/lib/scene/SUNCGLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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++) {
Expand Down
1 change: 1 addition & 0 deletions ssc/config/render_suncg.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"assetType": "scene",
"includeCeiling": false,
"useArchModelId": true,
"ignoreOriginalArchHoles": false,
"attachWallsToRoom": false,
"createArch": true
}
Expand Down
11 changes: 7 additions & 4 deletions ssc/render-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmd
.option('--assetType <type>', 'Asset type (scene or model)', 'model')
.option('--output_dir <dir>', 'Base directory for output files', '.')
.option('--output <filename>', '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 <material_type>')
Expand Down Expand Up @@ -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
});

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b66c108

Please sign in to comment.