DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Migrating to MRTK2: Mixed Reality Toolkit Standard Shader 'Breaks'

Migrating to MRTK2: Mixed Reality Toolkit Standard Shader 'Breaks'

Check out some of the common problems you might face when migrating to MRTK2.

Joost van Schaik user avatar by
Joost van Schaik
·
May. 08, 19 · Tutorial
Like (1)
Save
Tweet
Share
4.78K Views

Join the DZone community and get the full member experience.

Join For Free

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. Unsurprisingly, 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 to do it, as it forces me to adhere to the new style and learn how stuff works, without compromises. It also makes it 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 document any bumps in the road as I encounter them, as well as how I solved them. I hope other people will benefit from this, especially as I will be 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:

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 news, 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, it seems to look a bit different.

So, What Happened?

If you look at 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 the 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 an upgrade, and now, you know how to fix it, too.

Conclusion

I hope to have eliminated one source of confusion today, and I wish you a lot of fun watching the //BUILD 2019 keynote.

You can find a demo project here.

  • Branch "master" shows the original project with HoloToolkit
  • Branch "broken" shows the project upgraded to MRTK2 — with broken shaders
  • Branch "fixed" shows the fixed project
app News IT Branch (computer science) Diff unity Game engine Moment GitHub Document augmented reality

Published at DZone with permission of Joost van Schaik, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Agile Transformation With ChatGPT or McBoston?
  • Stream Processing vs. Batch Processing: What to Know
  • Ultimate Guide to FaceIO
  • Enabling DB Migrations Using Kubernetes Init

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: