Hello everyone.

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.
Options

Applying a texture to a room in the Emulator?

Does anyone know how you can apply a 3d texture to the spatial mapping graph in the emulator? I have a wireframe applied from Unity right now and it doesn't look great.

Basically, if I could get the room in the emulator looking like an actual room or something close to it, that would be great.

Best Answers

Answers

  • Options
    You can apply any material to the mesh, just change the reference from Wireframe to some other material. I'd recommend trying a non-textured material first with simple diffuse lighting.

    I've been playing with this also, although I'm not going for realism, and am struggling with UVs for the spatial mapping mesh, which causes textures to look terrible. I'll update the thread with more info this evening, hopefully a UV expert can help us out.
  • Options

    A texture might be tricky, but a shader that respects lights in the scenes could be used. The default diffuse shader in Unity will do this, and there are similar, but more performant, shaders in the HoloToolkit, such as 'StandardFast'. One note is that the normals in the spatial mapping mesh will need to be recalculated in the OnDataReady callback.

    IE, from the HoloToolkit:

    /// <summary>
            /// Handles the SurfaceObserver's OnDataReady event.
            /// </summary>
            /// <param name="cookedData">Struct containing output data.</param>
            /// <param name="outputWritten">Set to true if output has been written.</param>
            /// <param name="elapsedCookTimeSeconds">Seconds between mesh cook request and propagation of this event.</param>
            private void SurfaceObserver_OnDataReady(SurfaceData cookedData, bool outputWritten, float elapsedCookTimeSeconds)
            {
                GameObject surface;
                if (surfaces.TryGetValue(cookedData.id.handle, out surface))
                {
                    // Set the draw material for the renderer.
                    MeshRenderer renderer = surface.GetComponent<MeshRenderer>();
                    renderer.sharedMaterial = SpatialMappingManager.Instance.SurfaceMaterial;
                    renderer.enabled = SpatialMappingManager.Instance.DrawVisualMeshes;
                                      if(SpatialMappingManager.Instance.CastShadows == false)
                    {
                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                    }
                }
    
                surfaceWorkOutstanding = false;
            } 
    

    You'll need to add:
    surface.GetComponent<MeshFilter>().sharedMesh.RecalculateNormals();

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options

    @Patrick said:
    A texture might be tricky, but a shader that respects lights in the scenes could be used. The default diffuse shader in Unity will do this, and there are similar, but more performant, shaders in the HoloToolkit, such as 'StandardFast'. One note is that the normals in the spatial mapping mesh will need to be recalculated in the OnDataReady callback.

    IE, from the HoloToolkit:

    /// <summary>
            /// Handles the SurfaceObserver's OnDataReady event.
            /// </summary>
            /// <param name="cookedData">Struct containing output data.</param>
            /// <param name="outputWritten">Set to true if output has been written.</param>
            /// <param name="elapsedCookTimeSeconds">Seconds between mesh cook request and propagation of this event.</param>
            private void SurfaceObserver_OnDataReady(SurfaceData cookedData, bool outputWritten, float elapsedCookTimeSeconds)
            {
                GameObject surface;
                if (surfaces.TryGetValue(cookedData.id.handle, out surface))
                {
                    // Set the draw material for the renderer.
                    MeshRenderer renderer = surface.GetComponent<MeshRenderer>();
                    renderer.sharedMaterial = SpatialMappingManager.Instance.SurfaceMaterial;
                    renderer.enabled = SpatialMappingManager.Instance.DrawVisualMeshes;
                                      if(SpatialMappingManager.Instance.CastShadows == false)
                    {
                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                    }
                }
    
                surfaceWorkOutstanding = false;
            } 
    

    You'll need to add:
    surface.GetComponent<MeshFilter>().sharedMesh.RecalculateNormals();

    What class is this in? Where exactly in the HoloToolkit?

  • Options

    I should have said, it's HoloToolkit-Unity\Assets\HoloToolkit\SpatialMapping\SpatialMappingObserver.cs

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options

    That's awesome. :)

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options
    SaiSai
    edited April 2016

    @DeckTwelve said:
    RE: Texturing

    Today I found a TriPlanar shader which helped solve my texturing problem, your mileage may vary, but its worth a look.
    https://gist.github.com/radiatoryang/4725041

    RE: RecalculateNormals
    sharedMesh works for me in the Unity editor but results in a NullReferenceException in the emulator. MeshFilter.mesh.RecalculateNormals() works.

    Here's an video of it in action with a simple checkerboard texture.

    https://www.youtube.com/watch?v=igdrNpeS1dQ

    Exactly what we needed! Thank you!

    Sorry we are absolute beginners.
    How do we achieve this exactly?

    This is what we have right now
    This is what we have right now

    and this
    and this

    Right now we can't see anything in the emulator

  • Options

    Don't know if you managed or not, but all I did was make a new
    (with black and white at 100x100 pixels) and choose that for each side, results look good to me (you could make the black more gray if you want to look smoother but I prefer the black)

Sign In or Register to comment.