Reader small image

You're reading from  Become a Unity Shaders Guru

Product typeBook
Published inJul 2023
Reading LevelN/a
PublisherPackt
ISBN-139781837636747
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Mina Pêcheux
Mina Pêcheux
author image
Mina Pêcheux

Mina Pêcheux is a freelance content creator who has been passionate about game development since an early age. She is a graduate of the French Polytech School of Engineering in applied mathematics and computer science. After a couple of years of working as a data scientist and web developer in startups, she turned to freelancing and online instructional content creation to reconnect with what brightens her days: learning new things everyday, sharing with others and creating multi-field projects mixing science, technology, and art.
Read more about Mina Pêcheux

Right arrow

Taking advantage of shader branching and shader variants

When you first started your journey in the world of shaders and you took your first steps writing vertex and fragment functions, life was easy: you wrote a single piece of code that always executed the same (see the examples shown in the Appendix: Some Quick Refreshers on Shaders in Unity, or in Chapter 1).

But now that you are getting into more advanced rendering schemes, you might want to introduce some conditional behavior into your shader code so that it executes differently under different circumstances – for example, because of one of the following reasons:

  • You want to distinguish between two target platforms and their respective graphics backends
  • You don’t want to execute expensive code such as vertex inputs or large loops
  • You want your shader to sample a different texture depending on some instance-specific data

For all those cases, you might need to add some branching logic to...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Become a Unity Shaders Guru
Published in: Jul 2023Publisher: PacktISBN-13: 9781837636747

Author (1)

author image
Mina Pêcheux

Mina Pêcheux is a freelance content creator who has been passionate about game development since an early age. She is a graduate of the French Polytech School of Engineering in applied mathematics and computer science. After a couple of years of working as a data scientist and web developer in startups, she turned to freelancing and online instructional content creation to reconnect with what brightens her days: learning new things everyday, sharing with others and creating multi-field projects mixing science, technology, and art.
Read more about Mina Pêcheux