Intro
At this moment I am trying to learn as much as possible about the new Mixed Reality Toolkit 2, to be ready for HoloLens 2 when it comes. I opted for using a rather brutal cold turkey learning approach: I took my existing AMS HoloATC app, ripped out the ye goode olde HoloToolkit, and replaced it by the new MRTK2 - fresh from GitHub. Not surprisingly this breaks a lot. I am not sure if this is the intended way of migrating - it's like renovating the house by starting with bulldozering a couple of walls away. But this is the way I chose do it, as it forces me to adhere to the new style and learn how stuff works, without compromises. It also makes me very clear where things are going to break when I do this to customer apps.
So I am starting a series of short blog posts, that basically documents the bumps in the road as I encounter them, as well as how I swerved around them or solved them. I hope other people will benefit from this, especially as I will showing a lot of moved cheese. And speaking of...
Help! My Standard Shader is broken!
So you had this nice Mixed Reality app that showed these awesome holograms:
and then you decided to upgrade to the Mixed Reality Toolkit 2
and you did not expect to see this. This is typically the color Unity shows when a material is missing or something in the shader is thoroughly broken. And indeed, if you look at the materials:
something indeed is broken.
How to fix this
There is good new, bad news, and slightly better news.
- The good news - it's easy to fix.
- The bad news is - you have to do this for every material in your apps that used the 'old' HTK Standard shader
- The slightly better news - you can do this for multiple materials in one go. Provided they are all in one folder, or you do something nifty with search
So, in your assets select your materials:
Then in the inspector select the Mixed Reality Toolkit Standard Shader (again) :
And boom. Everything looks like it should.
Or nearly so,because although it carries the same name, it's actually a different shader. Stuff actually might look a wee bit different. In my sample app, especially the blue seems to look a bit different.
So what happened?
If you look what Git marks as changed, only the tree materials themselves are marked changed:
and if you look at a diff, you will see the referenced file GUID for the shader is changed. So indeed, although it carries the same name (Mixed Reality Toolkit Standard), as far as Unity is concerned it's a different shader.
(you might want to click on the picture to be able to actually read this).
As you scroll down through the diff, you will see lots of additions too, so this is not only a different shader id, it's actually a different or new shader as well. Why they deliberately chose to break the shader ID - beats me. Maybe to make upgrading from one shader to another possible, or have both the old and the new one simultaneously work in one project, making upgrade easier. But since they have the same name, this might also induce confusion. Whatever- but this is what causes the shader to 'break' at upgrade, an now you know how to fix it, too.
Conclusion
I hope to have eliminated once source of confusion today, and I wish you a lot of fun watching the //BUILD 2019 keynote in a few hours.
You can find a demo project here.
1 comment:
You just keeping doing it. #ByExampleIndeed #Kudos
Post a Comment