08-04-2021



An occlusion map is a greyscale image, with white indicating areas that should receive full indirect lighting, and black indicating no indirect lighting. Sometimes this is as simple as a greyscale heightmap A greyscale Texture that stores height data for an object. Trees must use the Nature/Soft Occlusion Leaves and Nature/Soft Occlusion Bark shader. In order to use those shaders you also have to place the tree in a special folder that contains the name 'Ambient-Occlusion'. When you place a model in that folder and reimport it, Unity will calculate soft ambient occlusion specialized for trees. Now I stumpled upon the integrated Beast lightmapping in Unity which would serve me better as I like to manage all my objects within Unity. Problem now is: I have trees which consists of 2 materials / textures which I have defined as having 'Nature/Soft Occlusion Bark' and 'Nature/Soft Occlusion Leaves'. My floor is having a normal diffuse shader. Tip 2: I also heard TITAN RTX is quite effective at machine learning. I'm looking at you, Unity ML Agents 😉 I'm personally looking forward to using the TITAN RTX for the upcoming ray-tracing posts. I aim to give you a solid insight on the possibilities of ray-tracing with Unity so that you can differentiate your game from the rest. Theses occlusion data are a 4d vector. The x, y and z coordinates of the ambientocclusion vector store the bent-vector, and the W coordinate stores the occlusion factor. This occlusion factor is then used in pixel shader to modulate the ambient intensity. In this shader, the bent-vector is not used.

Last Updated: Jun 4, 2017

  1. Add occlusion to the scene
  2. Fix Voice command to swap between grid and occlusion
Occlusion Shader Unity

Every time I show this demo to people I highlight the problems that are caused by not having the real world occlude your holograms. The picture above shows an example of this problem, can you tell which sphere is covered by the wall and which isn’t? Although it appears that the one on the right should be occluded, they both should be. This tutorial shows how to fix this.

This became very easy to accomplish due to PR#663 on the HoloToolkit done by RafaƂ LegiędĆș. Take a look at the code changes here:

These changes allow the Material to be updated while spatial understanding is running. This allows us to switch the material to the any other material and have the surface update in real time. Open ObjectPlacer.cs in Visual studio and change this method to have the following code:

Occlusion

Ambient Occlusion Unity

Open your scene in Unity and Select Placement in the Hierarchy. Set Occluded Material in Object Placer to the Material “Occlusion”. The properties should look like this:

That’s it! Build and Deploy the project. Notice that after spatial understanding is complete and the world is generated there is now occlusion with the real world. Stand behind a real world object that blocks your view of a hologram. Try having a hologram partially blocked. This seems like it totally solves the problem, but be warned, this level of occlusion highlights every flaw in your spatial mesh, so use this technique carefully.

In a previous tutorial we created a voice command that looked like this:

Due to the addition of occlusion this no longer works, lets correct the “Toggle” command to only work after we have finalized the spatial mesh and to swap between occlusion and the grid visualizing the spatial mesh. Editthe Speech.cs file to look like this:

On Start we store a copy of the Spatial Understanding Mesh Material which is the standard Spatial Understanding Grid. When the voice command for toggle is received we first make sure that spatial understanding is completed before we do anything. If it is complete we swap the currently displayed material for the material we have stored. This allows us to toggle between the occluded material and the grid.

Build and Deploy the application. You should be to speak the word “Toggle” after you have finalized the spatial mesh to switch between the grid and occlusion.

Occlusion Shader Unity Versions: Unity 2017.1.0p5

Ambient Occlusion Shader Unity

|

Nature Soft Occlusion Shader Unity

Nature soft occlusion shader unityMixedRealityToolkit-Unity v1.2017.1.0 | Visual Studio 2017 15.3.2Occlusion shader unity mod
Unity 3D Project CreationHow to create a HoloLens project in Unity 3D
Source ControlConfigure git for HoloLens / Unity work
Spatial MappingHow to spatial map a Room
Object Surface ObserverSet up fake spatial map data for the Unity editor
TagAlongs and BillboardingTag along instructions to the user to force text on screen
Spatial UnderstandingAdd spatial understanding to get play space detail
Finalizing Spatial UnderstandingComplete Spatial Understanding and Input Manager
Object Placement and ScalingFind valid locations for holograms in the play space
Hologram ManagementManage the holograms you want to place in the world
Cursor and VoiceAdd a cursor and voice commands
OcclusionAdd occlusion with the real world to your scene
Colliders and RigidbodysAdd Colliders and RigidBodys to your holograms
  • Download the completed app Western Town in the Windows Store!
  • Completed Source code from the entire tutorial available onGitHub.