[Tutorial] How to copy lightmaps and lights from one scene to another

In the case you get the dreaded “Scene failed to load. Reload the page to retry.” error (Which I’ve now learned may be solved by simply re-uploading your scene to the cloud), or simply want to make a duplicate of your scene without transferring material settings, I wanted to document the process I’ve backwards engineered. This may help root out other materials issues, but the point of this is to document some of what’s happening behind the scenes for the sake of scene debugging.

Import your model file as a new scene.

Using Notepad++, navigate to your C:\Users<user>\Documents\Shapespark folder and find your source scene’s folder in there, e.g. “Model 01”

The cover.json file holds the Viewer info, such as material selection sets. You can copy this file to the target scene folder, e.g. “Model 01 Copy”

Using Notepad++, open the scene.json file from both your source and target folders. Now we’ll do a compare. (Note, you may need to add the Compare Plugin to Notepad++ by going to Plugins–>Plugin Admin and searching for Compare, checking the box and installing it.) Now we can do a compare by going to Plugins–>Compare–>Compare.

On the following pics, the target is on the right and the source is on the left. We can see there lightmap and lights info is all towards the front of the line. (Use View–>Word Wrap to see the single line across the full page height).

We can see the lightmap and light info is stored just after the “atlases” section. If you don’t have atlases info, you’ll need to bake and upload your scene to the cloud so it generates the texture atlases and optimized textures. That’s not required to copy the light info, but for the sake of this tutorial both the source and target scenes have been baked and uploaded so their scene.json files are as similar as possible.

Here we can see on the target scene “lights”:[] is empty. We’ll need to copy the info from the source between the [ ] brackets on the target. Save the target scene and now you’ll have all of your lights copied from the source to the target.

Next we’ll do the same for the Light Probes. The chunk of data starting with “autoAddLightProbes”:false to ,“lights” (that we’ve just filled in). Be sure that you’re copying commas from source to target code where needed. That takes care of copying the Light Probes.

You cannot copy materials reliably using this method alone as their texture atlas coordinates are likely different between the source and target. For that you’d need to copy over the atlas files, etc, but I’ve found it’s easier to simply use the Shapespark editor to change the materials as needed.

Hope this helps someone!

2 Likes

BTW, for analyzing/editing scene.json you might find it helpful to get a formatted version of the file. When the Shapespark desktop application is running, it’s available under the following URL:

http://localhost:5000/scenes/SCENE-NAME/scene.json?pretty

1 Like

Wow, that’s great! So much easier to see what’s going on. I take it this scene.json can be edited and saved in place of the one in the scene’s root folder?

As a tip for others, you can also open URLs in Notepad++ by going File–>Open and pasting the URL into the open filepath:

1 Like

That’s right. Just remember that if you change something in the scene editor you have to read scene.json from the URL once again.

1 Like