Workaround: Remote Texture Loading Does Not Work With MRTK Standard Shader
Having trouble with remote texture loading on your MRTK Standard Shader? Check out this post to learn more about the workaround that can save you some trouble.
Join the DZone community and get the full member experience.
Join For FreeThis is one of those things that can cost you hours to fix and drive you completely crazy. I was working on a new improved version of my HoloLens/Mixed Reality app AMS HoloATC, and this version was using a dynamic OpenStreetMap for geographical reference. So, I stole the OpenStreetMap slippy map from my own work. But, times have moved on, and I wanted to use the new Standard Shader from the Mixed Reality Toolkit, instead of the Unity Standard Shader, to be able to use the cool fluent effects, like the Hover Light.
Unfortunately, I not only got some fluent options that worked beautifully but also some problems. If I used my DynamicTextureLoader that I wrote about like 1.5 years ago to download map tiles from the Internet, nothing happened. The texture is downloaded and applied, but it never shows up.
To show you what it looks like, I made a demo project:
And as you can see on the most right picture, I got it to work as well.
The trick is in the materials. The difference is hard to spot, but one of the panels using an MRTK standard already has a dummy texture at startup:
This is fairly easy to achieve, like this:
It's a file of literally one white pixel. This suggests that there is something in the MRTK Standard Shader that looks for textures at startup, and if there is no texture present, subsequent changes of the texture are ignored. I don't know if it's a bug or intentional — some kind of performance optimization — but this trick gives you textures and fluent stuff.
A little demo project showing this trick can be found here.
Published at DZone with permission of Joost van Schaik, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments