The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Spatial Mapping From Scratch

Firstly, I've gone through all the 101E examples successfully by following the instructions point by point.
I'm now having trouble getting the spatial mapping mesh to render when I try to do it from scratch.
Expected Result
I see rendering of the emulated room
Actual Result:
Nothing renders and I only see black
Here's what I am doing:
Unity Code
- Create a GameObject and attached a script with the exact code as the
Spatial Mapping Example in 101E - Imported the Wireframe file (no extension) and its .shader file
- Dragged the .shader file to the no extension Wireframe file in Unity (to associate the two)
- Associated the Wireframe as the Material in the script
- Checked the "Draw Visual Meshes"
- Though unnecessary (since the example didn't need them for rendering), I added the
"Spatial Mapping Renderer"
and
"Spatial Mapping Collider"
components and set them with the same settings as in 101E.
Unity Config
- a) Go to Edit > Project Settings > Player~~~~
b) Under Publish Settings > Capabilities, check the "SpatialPerception" box - a) Edit > Project Settings > Quality
b) Set the Windows projects to "Fastest" - a) File > Build Settings
b) Added Open Scenes and made sure it was checked
c) Player Settings > Other Settings > Virtual Reality Support is checked and "Windows Holographic" is listed
d) Highlight Windows Store
SDK = Windows 10
UWP Build Type = D3D
Checked "Unity C# Projects"
e) Click "Build"
Visual Studio
- I opened the App > .sln file
- I edited the Package.appxmanifest file to say "Windows.Holographic" vs "Windows.Universal"
- Set it to "Release","x86", and the Hololens Emulator
- Debug > Start without Debugging
Note:
I've also deployed this to the Hololens hardware with the same results, so it's not an emulator issue.
Hopefully I've done something obviously wrong that you experienced gurus can point out.
I feel like there's some project settings or some prefab generation steps that I'm missing. I'm going to go through the 230 course to see if there's something in there that they glazed over the intro.
Rant
I wish the tutorials would take you step by step from scratch vs just opening their Origami project and copying their prefabs into the project. This is a really good way to get people excited because of how easy it is, but it becomes really frustrating once you run into issues doing something on your own.
Best Answer
-
ahillier mod
Hi @fq76,
Verify that you had the Windows Store tab (green icon) selected when you checked the 'Virtual Reality Supported' option, as Unity does not typically default to this view.Also, you must check the 'SpatialPerception' capability before generating a VS solution, because VS won't pick up changes made to Project Settings automatically. If you happened to set these options after building from Unity, delete your build folders (App and UWP) and then rebuild from Unity. You can also right-click on the 'Package.appxmanifest' file in VS and choose 'view code', to verify that your app was built with the correct capabilities:
Here is how you get Spatial Mapping to work (in the most minimal way possible):
1) Create an empty GameObject in you Hierarchy and rename it 'SpatialMapping' (or whatever you wish).
2) With the 'SpatialMapping' object highlighted, select the 'Add Component' button in the Inspector.
a) Add the 'Spatial Mapping Renderer' component to visualize the meshes.
i) Set 'Custom Render Settings' to 'Custom Material', which will render a colored wireframe material (SpatialMappingWireframe) which is already provided by Unity. Or swap this with the white wireframe material that you copied to the project.
b) Add the 'Spatial Mapping Collider' component if you need to use physics or place holograms on real-world surfaces.That's all you need to do to render spatial mapping in your app. To do anything more advanced (like swap between the wirefame material and occlusion material), then you'll want to write a helper script. In Holograms 101 (Origami), the prefab had a 'SpatialMapping' script attached to it, which provided some helpers for swapping materials, and enabling/disabling the components. Be sure to take a look at that script to understand how the code is being used in the project.
Holograms 230 is a more advanced approach to Spatial Mapping. It teaches you how to use the underlying 'Surface Observer' for getting and updating meshes. This class does not use the 'Spatial Mapping Renderer' and 'Spatial Mapping Collider' components that Unity provides (mainly because these components did not exist until recently).
Thanks for your feedback (even rants are good)! Spatial Mapping is one of the more advanced features and how we use/teach it has changed multiple times over the last year. By providing a Unity prefab, we were able to minimize changes to the course instructions and keep the tutorial in-sync with the video recordings. You will find that we use prefabs heavily for more advanced courses/features, as they're the best way to ensure that students are using the correct components and settings in order to succeed in the course. Still, if there are particular areas that you find confusing, especially after looking over the prefabs and attached scripts, be sure to let us know!
I hope this helps,
~Angela7
Answers
Hi @fq76,

Verify that you had the Windows Store tab (green icon) selected when you checked the 'Virtual Reality Supported' option, as Unity does not typically default to this view.
Also, you must check the 'SpatialPerception' capability before generating a VS solution, because VS won't pick up changes made to Project Settings automatically. If you happened to set these options after building from Unity, delete your build folders (App and UWP) and then rebuild from Unity. You can also right-click on the 'Package.appxmanifest' file in VS and choose 'view code', to verify that your app was built with the correct capabilities:

Here is how you get Spatial Mapping to work (in the most minimal way possible):

1) Create an empty GameObject in you Hierarchy and rename it 'SpatialMapping' (or whatever you wish).
2) With the 'SpatialMapping' object highlighted, select the 'Add Component' button in the Inspector.
a) Add the 'Spatial Mapping Renderer' component to visualize the meshes.
i) Set 'Custom Render Settings' to 'Custom Material', which will render a colored wireframe material (SpatialMappingWireframe) which is already provided by Unity. Or swap this with the white wireframe material that you copied to the project.
b) Add the 'Spatial Mapping Collider' component if you need to use physics or place holograms on real-world surfaces.
That's all you need to do to render spatial mapping in your app. To do anything more advanced (like swap between the wirefame material and occlusion material), then you'll want to write a helper script. In Holograms 101 (Origami), the prefab had a 'SpatialMapping' script attached to it, which provided some helpers for swapping materials, and enabling/disabling the components. Be sure to take a look at that script to understand how the code is being used in the project.
Holograms 230 is a more advanced approach to Spatial Mapping. It teaches you how to use the underlying 'Surface Observer' for getting and updating meshes. This class does not use the 'Spatial Mapping Renderer' and 'Spatial Mapping Collider' components that Unity provides (mainly because these components did not exist until recently).
Thanks for your feedback (even rants are good)! Spatial Mapping is one of the more advanced features and how we use/teach it has changed multiple times over the last year. By providing a Unity prefab, we were able to minimize changes to the course instructions and keep the tutorial in-sync with the video recordings. You will find that we use prefabs heavily for more advanced courses/features, as they're the best way to ensure that students are using the correct components and settings in order to succeed in the course. Still, if there are particular areas that you find confusing, especially after looking over the prefabs and attached scripts, be sure to let us know!
I hope this helps,
~Angela
Hey Angela,
Much appreciated for the detailed response! I didn't know the UWP was also a build folder, so that helped with generating a clean build.
Great tip to check the Package.appxmanifest to double check the capabilities. It's all working great now!