Back to List

Making it Snow with a HoloLens

Greg Levenhagen Greg Levenhagen  |  
Dec 22, 2016
If you’re hoping for a white Christmas, the HoloLens can help! This post will walk through the steps of creating a snowing app in augmented reality/mixed reality and what that looks like on a HoloLens. 

I’m using Unity, the HoloToolkit and a Particle System for this approach. The HoloToolkit provides open source code to help developers incorporate things like Input, Sharing, Spatial Mapping, Spatial Sound, Miscellaneous Utilities and Building of projects. 

Exporting HoloToolkit 
The first step is setup our Unity project to use the HoloToolkit. I prefer to clone the GitHub repository for working with in my local environment. 

Once you have the HoloToolkit downloaded, open the folder containing HoloToolkit in Unity, then in the Project window, right click the Assets folder and then select Assets -> Export Package. You can include everything and all dependencies. This will create a *.unitypackage file that can be imported into your other Unity projects.

Importing HoloToolkit
Now inside a new Unity project, right click the Assets folder again and select Import Package, then select Custom Package.

Browse to where your *.unitypackage file was saved and import it.

Setting Up Unity for HoloLens
Now we want to setup the Unity project for HoloLens development. Let’s start out by saving our Scene and giving it a name. In the Hierarchy windows, right click the Untitled scene and click Save Scene. This will ask you for a folder location and a name.

Next, we want to get the Camera setup. Right click and select Delete on the Main Camera, as we’ll replace it with one from the HoloToolkit. You can optional delete the Directional Light object, too.

Now in the Project Windows, browse to the Assets -> Input -> Prefabs folder so that you see HoloLensCamera. Drag the HoloLensCamera Prefab into the Hierarchy window under the Scene.

The HoloLensCamera has set the Clear Flags to a Solid Color with a Background of black, which allows the HoloLens to see the real world. It also has a Manual Gaze Control component to allow for camera control using a keyboard or mouse in Unity.

As part of importing the HoloToolkit, you should now have a HoloToolkit dropdown menu option in the main Unity menu. You need to individually select the Apply HoloLens Scene Settings, Apply HoloLens Project Settings and Apply HoloLens Capability Settings. The Project Settings may ask you to restart Unity, which is okay, but make sure you save changes when it asks.

For the Apply HoloLens Capability Settings, make sure to check the box for SpatialPerception, because we want to use that in our app.

The Snow Particle System
In order to have snow, I’ve chosen to use a Particle System. Add a Particle System by right clicking the Scene, selecting GameObject -> Particle System. After it’s added, you can right click and rename.

With the Particle System selected in the Hierarchy window, the Inspector window should look something like the following.

We want to change several of the settings. To start, let’s change the value of Start Lifetime to 10 and Duration to 10. This means the particles will die after 10 seconds and that the loop will last for 10 seconds. You could make this longer if you want the snow to still around.

For the start size, we want something that changes the snowflake size. Select the dropdown arrow on the right-hand side and select Random Between Two Constants. I have 0 and 1, but you can enter whatever you like.

The Gravity Modifier should be changed to a small value, like 0.05, so the snow falls down. Change the Simulation Space to World. Finally, change Max Particles to 5000 to provide more snow! Your SnowParticleSystem main properties section should now look like the following.

Under the Emission property section, you can increase the Rate over Time to make it snow more quickly.

Within the Shape property section, we need to change how the snow is produced. There are a lot of choices and we’ll go with a Box. Set the X and Y values to 10 and the Z value to 1. Depending on your area, you can adjust these values.

This produces a box, which we’re really treating like a plane for our purposes, to emit the snow particles.

Next, check the box for Collision and expand the property section. The top of this section will default to Planes and that should be changed to World. The next two values of Dampen and Bounce need to change so the snow hits an object and stays in place. To achieve this effect, the Dampen value should be set to 1 and the Bounce value should be set to 0.

We then adjust the Radius Scale to make the bounds for collision detection roughly match the size of a snowflake. I’ve increased the max collision shapes to improve collision checking, but reduced the quality for speed.

Now on to the Renderer property section. We want to change the Sort Mode to Distance. The Max Particle Size is something you may need to try different values, but let’s start out with 0.05.

Positioning the Snow Particle System
You may have noticed that the particle system is on top of our camera, so let’s move the particle system to have the snow falling over the camera. Within the Inspector window, find the Transform component and set the Y Position value to 10. If the snow isn’t falling over the camera, make sure the X Rotation value is set to 90.

Your Scene window should have something like the following. Notice the camera within the falling snow.

Adding Wind
With the SnowParticleSystem selected in the Hierarchy window, select Add Component in the Inspector window. Start typing Wind into the search bar and then select Wind Zone.

The Wind Zone component will add a 3D arrow to your scene as follows.

You can alter the values to adjust how the Wind manipulates the particles. Let’s set Pulse Magnitude to 1 and Pulse Frequency to 0.5.

In order for the Wind to have an effect on the particles, we need to tell the particle system to allow for external forces. Under the Particle System component, check the box for External Forces. At this point, you can play around with the Wind Zone. Keep in mind that we added the Wind Zone component to a Box based Particle System, so the Wind is blowing down. If you want to have a cross wind or some other effect, you’ll want to add another object to the scene and add a Wind Zone component to that new object.

Making the Snow Interact with Real Objects
If you were to run this project in your HoloLens, the snow would fall through real world objects, but we don’t want that. Let’s make it so the snow hits the floor and other objects in your real world.

Start by selecting the HoloLensCamera object in the Hierarchy window. We want to add some components in the Inspector window, so click Add Component. Do this twice and select Spatial Mapping Collider and Spatial Mapping Renderer.

In the Spatial Mapping Renderer property window, change the Render State from Occlusion to Visualization. This will allow you to see the triangles representing what the HoloLens sees as it maps out your environment. At this point, your snow particles should somewhat be stopping when they hit real world objects. I say somewhat because the size of the particles and what is getting used for a comparison isn’t a clean plane of the floor or other objects.

Give it a go at this point. You should have a decently running app. Remember to run it as Release, x86 and without debugging for best performance.

Changing it Up to Use Planes
The Spatial Mapping Renderer and Spatial Mapping Collider are provided by the HoloToolkit and give us a great start to interacting with real world objects. For more information about the Spatial Mapping, please visit

As a next step to extend this exercise, you could add the ability for using planes. The HoloToolkit has a PreFab for SpatialMapping in the HoloToolkit -> SpatialMapping -> Prefabs folder. Drag that into your scene. I’ve left the defaults for this PreFab, except for loading a Room Model to use with the Unity Editor.

You would then need to Create an Empty GameObject to your scene and call it something like SpatialProcessing. On this object, you will need to add the SurfaceMeshesToPlanes script that is included with the HoloToolkit.

You can optional add the RemoveSurfaceVertices script to make processing easier.

Finally, you’ll want to do something with the planes, like make sure they’re part of the World so that the Particle System can collide with them. Remember, we configured the Particle System to interact with the World. We could go back and specify collision to occur with Planes and add code to dynamically add the SurfaceMeshesToPlanes results to the Collision planes.

The HoloToolkit provides a sample test script for doing Spatial Processing called SpatialProcessingTest, so let’s add that onto our SpatailProcessing object. Your SpatialProcessing object should now look close to the following.

You’ll need to add the SurfacePlane PreFab as outlined above by selecting the Asset -> SpatialMapping -> PreFabs folder and finding it. This is will get used to instantiate any planes detected by the SurfaceMeshesToPlanes script. Using the drop downs for Draw Planes and Destroy Planes, you can configure which planes should make it into your World. Adjust the Scan Time for the Spatial Processing Test to configure how long the scanning of your world runs.

Note: If you don’t want to see the spatial mapping triangles or planes, you can back and change those Materials to Occlusion.

Give it go! Let us know how it went for you in the comments.

As you can see, working with Unity and Visual Studio can produce some very interesting effects when using a Microsoft HoloLens. We saw how a Particle System can be used to generate a snow-like effect in our real world and the HoloLens SDK and HoloToolkit help get us going.

The HoloLens has tremendous potential! At Skyline, we’re actively working with our clients on HoloLens projects and new innovative ways to improve their businesses. If you’re interested, please reach out and we would love to discuss opportunities with you.


Love our Blogs?

Sign up to get notified of new Skyline posts.


Related Content

Blog Article
Developing on a Raspberry Pi using Gulpjs
Eric DitterEric Ditter  |  
Jan 15, 2019
Developing on one machine and running on another is a tedious process, but sometimes you need to when a library has different features for ARM vs x64 (and then there are always the Windows vs Linux issues). This was the issue I had when I was working on a Raspberry Pi project using Python...
Blog Article
CQS, SimpleInjector, and the Power of Decorators
Dan LorenzDan Lorenz  |  
Jan 08, 2019
Over the years of developing with n-tier style, I was wondering if there was anything else out there. The biggest problem with n-tier for me is that the interfaces and classes tend to get super large. When that happens, you start breaking SOLID principals and unit testing becomes much more...
Blog Article
Async, Await, and ConfigureAwait – Oh My!
Dan LorenzDan Lorenz  |  
Dec 11, 2018
In .NET Framework 4.5, async/await keywords were added to the language to make async programming easier to work with. In order to maximize device resources and not block UI, you should really try to use asynchronous programming wherever you can. While async/await has made this much easier than...
Blog Article
How to Add Electronic and Digital Signatures to a Universal Application (UWP) with iText
Paul MadaryPaul Madary  |  
Aug 14, 2018
When paying for gas at the pump, checking out at Walmart, or electronically signing a contract to purchase real estate, have you ever thought about what technically goes into that electronic signature?  If not, then this is your lucky day! I recently had to implement this functionality in a...
Blog Article
Updated Mile of Music App Provides an Even Better User Experience
John PtacekJohn Ptacek  |  
Jul 26, 2018
As we get to the end of July at Skyline Technologies, our organization starts to get excited. We know that the Mile of Music festival is just around the corner. With over 70,000 people coming to Appleton, Wisconsin, for four days of original music, it is quite an adventure. Given one of the main...