Workaround: remote texture loading does not work with MRTK Standard Shader

1 minute read

imageThis 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 in stead of the Unity Standard Shader, to be able to use the cool fluent effects like the Hover Light and stuff.

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, applied - but it never shows up.

To show you what it looks like, I made a demo project:

image

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 a MRTK standard already has a dummy texture at startup:

image

This is fairly easy to achieve, like this:

image

It's a file of literally one white pixel. This suggests there is something in the MRTK Standard Shader that look 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 tricks gives you textures and fluent stuff.

A little demo project showing this trick can be found here.