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.

Avoidance of passing holograms through the user. The smooth changing of the level of "transperency".

Hello guys!

While I was reading Hologram article (https://developer.microsoft.com/en-us/windows/mixed-reality/hologram), I've found something really exciting about how we can avoid the degradation of user's experience. Here is the bulk logic:

Two meters is the most optimal, and the experience will degrade the closer you get from one meter. At distances nearer than one meter, holograms that regularly move in depth are more likely to be problematic than stationary holograms. Consider gracefully clipping or fading out your content when it gets too close so as not to jar the user into an unexpected experience.

In terms of the last sentence, I don't really know to realize smooth fading as we get closer and closer to the hologram. I personally think that this functionality works as follows:

The distance between user and hologram is 0.5m, so than the variable which will be called fadingFactor = 0.5f, if the distance will equal 0.2m, so than fadingFactor = 0.8f and so on. Consequently, if the distance between user and hologram is critical, so than that hologram should be fully transparent.

So, those who is already worked with something like this, please have a feedback.

All the best,
Andrew

Best Answer

Answers

  • Take a look at the shaders in the MixedRealityToolkit-Unity project. They use a NearPlaneFadeDistance to achieve this.

  • @timg said:
    Take a look at the shaders in the MixedRealityToolkit-Unity project. They use a NearPlaneFadeDistance to achieve this.

    I'll check this out. Thank you. If it works, I'll vote up :smiley:

  • @AndrewMilko said:

    @timg said:
    Take a look at the shaders in the MixedRealityToolkit-Unity project. They use a NearPlaneFadeDistance to achieve this.

    I'll check this out. Thank you. If it works, I'll vote up :smiley:

    I'm a beginner and can't really understand how to add this property to my object's shader?! Please, help)

  • @AndrewMilko The easiest thing to do is to use one of the built-in shaders from the MixedRealityToolkit (such as FastConfigurable) and then to add the NearPlaneFade script to you camera.

    If you need to convert an existing shader of yours to work with the NearPlaneFade script, I would suggest looking at one of the simpler shaders in the toolkit to see how it handles things there:
    https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/master/Assets/HoloToolkit/Utilities/Shaders/Obsolete/UnlitConfigurable.cginc

    Its pretty simple, but in the vertex shader, you figure out the fade amount:

    o.fade = ComputeNearPlaneFadeLinear(v.vertex);
    

    And then in the fragment shader you multiply the final output color by the fade amount:

    c.rgb *= i.fade;
    
  • @thebanjomatic said:
    @AndrewMilko The easiest thing to do is to use one of the built-in shaders from the MixedRealityToolkit (such as FastConfigurable) and then to add the NearPlaneFade script to you camera.

    If you need to convert an existing shader of yours to work with the NearPlaneFade script, I would suggest looking at one of the simpler shaders in the toolkit to see how it handles things there:
    https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/master/Assets/HoloToolkit/Utilities/Shaders/Obsolete/UnlitConfigurable.cginc

    Its pretty simple, but in the vertex shader, you figure out the fade amount:

    o.fade = ComputeNearPlaneFadeLinear(v.vertex);
    

    And then in the fragment shader you multiply the final output color by the fade amount:

    c.rgb *= i.fade;
    

    First of all, thank you for contacting! It does your credit :wink:

    1) If I'm using built-in shaders from "MixedRealityToolkit" everything works great but in terms of where I need to add that NearPlaneFade script, I can't really understand why we were need to add that thing to the camera. I have everything working when that script is attached only to the hologram which should be transparent sometimes. So, what's the difference if I add this script only to the hologram or only to the camera?

    2) As described later, I've used only built-in shaders for creating this effect but to convert an existing shader of mine to work with the NearPlaneFade script - that is not really clear for me. I wish you gave me some advices how to work with .cginc files. I don't know for what we are using them. Do I need to use it to create changes in my own shader or not? For instance, I'm using SpeedTree shader from Nature folder in the shaders' hierarchy. If it's possible could you direct me what I need to do to have my shader that functionality? I just can't clearly see what lines of code I need to add to my object's shader.

    Thank you so mush, that I just can't imagine. You are out of this world! :smile:

Sign In or Register to comment.