Unity Shader Getting Started Guide2023.05.11

foreword

It is said that the learning curve of Unity Shader is very steep. I want to learn but I don’t know where to start. After reading a few books, it seems that I am still in the fog. When it comes to mathematics and physics knowledge-directly persuade me to quit.

This is a problem that most novices will encounter, so this article is not to explain some theoretical knowledge, because those books have it, or some column blogs have also explained it clearly.

The purpose of this article is to solve the problem of steep shader learning curve and learning route planning.

If you want to learn more about getting started.

Recommend some entry-level columns.

Unity technical art - Know almost

Xiaobai's Unity Shader study notes-Knowledge

Shader from entry to running - Know about

Two books are recommended.

 

 After clarifying the purpose of writing this article, let me say that this article mainly consists of two parts

  • study method
  • Basic Knowledge Framework

I will help you reduce the difficulty of learning shader from these two dimensions, and then I will start with the learning method.

efficient learning method

1. Understand the Big Picture

Former US Secretary of Defense Donald Rumsfeld once said "unknown unknowns", that is, you don't know that you don't know.

Before learning shaders, we actually don't know what we don't know, or even what a shader is.

So, we took a book and started to read, or found online tutorials, and watched episode by episode.

After watching it for two days, the learning curve suddenly soared, and I thought to myself, "It really is from getting started to giving up".

In fact, the problem is that in this process, you either learn more than you need, or you are beyond your capacity.

Therefore, we should first understand the field of computer graphics and what is involved in this field, so that we can figure out what we want to learn, and then find out the best way to learn.

The way to understand the overall situation can be to find a few related books on the Internet, and then collect the contents in the catalog, such as this.

But don't spend too much time on this step, because the purpose of this step is not to master the topic, but to have a global understanding of the relevant content.

2. Determine the scope

Within a certain period of time, it is impossible for us to master all shader knowledge, we need to determine the focus and scope of learning. If we want to learn how to make toon shading effects, this is a learning area, and if we want to learn how to improve rendering performance, this is another learning area.

In this step, we can easily make the mistake of trying to solve too big a problem and overwhelm ourselves. Therefore, we also make good use of the information obtained in the previous step to allow our focus to fall into a smaller controllable range.

3. Define your goals

After clarifying the scope of learning, we should clarify the criteria for success, so that we can use the backward method to clarify the steps needed to achieve the goal.

Bad success metric: I learned the basics of shaders

Good success criteria: I can write a toon shading effect using the shader and it runs successfully in Unity.

Such standards will allow you to approach your goals faster and more accurately.

4. Find resources

When we have determined our goals, we need a variety of learning resources to help us learn, instead of just reading a related book.

I usually open Amazon first, then search for related books, and send the sample chapters to my mobile phone or computer.

I will also look at the Douban rating and review content of the books I found.

Then open YouTube, search for related videos, open Zhihu, search for relevant columns and articles, open the search engine, and search for blog articles.

This is done because I feel that a single piece of information is more prone to bias. The information on videos or blogs is not authoritative or even misleading, and the content in books is often too official and difficult to understand.

5. Create a study plan

The table of contents in the book is often written according to the author's own wishes, but some books are poorly structured, and some books exceed your needs. In this step, you need to establish your own learning path and create your own learning plan according to the subjects you are interested in. In the end, we will find that our learning path is very similar to the catalog of a book, basically completing the goal.

6. Filter resources

In step 4, we found a lot of resources, but according to the study plan, a lot of data is redundant, we need to browse all of them to find out which content can cover our study plan, and then buy a book or two. Book worth it.

After the above steps are completed, we can start learning knowledge.

7. Start learning

For ordinary programming languages, creating a "Hello, world!" is the first step. For us to learn shaders, it is also the first step to create the most basic shader that does not report errors (turn pink).

The key to this step is to go too far, because we can easily lose self-control and start digesting all the resources in the study plan.

What we need is to focus on mastering the minimum amount of knowledge we need to be able to take the next step.

Why do you want to get started? Let me give you an example.

When we play the game, we don't start the game after learning all the operation instructions and strategies.

For example, when playing League of Legends, I prefer the hero 36D Qinnv based on my previous understanding. After playing two games, I have a certain understanding of the hero’s skill effects, casting distance, and lane skills, and I have a lot of ideas. Doubts, such as what equipment should I produce? Where should I cast my eyes? Can I play other positions besides support?

Now we start to look up strategies, watch videos, study these issues, and then practice.

When we do this process repeatedly, it is actually when we make the most progress.

With this method of learning, the brain will naturally generate various questions. When looking back to find the answers to the questions, these questions will not only be solved, but also learn more things, because what you learn is very important to you s things.

Curiosity is an important part of self-study. When we found some unanswered questions through hands-on operation, out of curiosity, we would go back and read the materials to solve the problems accumulated in the process and seek answers.

So we must not be afraid to go back and read the operation again, and this time mainly solve the problems found in the hands-on process. Each module we master should push us towards our ultimate goal in this way.

8. Enjoy being a teacher

Most people don't dare to be teachers, but there is nothing to be afraid of. Sometimes experts who are too far ahead of students can't wait to teach handily, because they can't empathize with students, and they have forgotten the beginners. It's easy to focus on what they think are simple details, which is one of the reasons why I think the shader learning route is so steep.

When you want to teach others knowledge, it is also a good way to check for gaps and make up for omissions. You need to analyze what you have learned, and then internalize it into your own thoughts, which will improve your understanding of shaders to a higher level.

For example, I write columns and articles on Zhihu, which is actually my way of checking for gaps and filling in gaps, and I also hope to help more people.

Basic Knowledge Framework

The following is the knowledge that I think is necessary to understand at the entry stage from a macro perspective

Principles of Classical Graphics

Why do you need to understand the principles of graphics first?

Because what we have to do is to use computer language to deceive the user's vision, and after understanding the basic principles of graphics rendering, it will reduce the difficulty for us to understand shaders, that is, it can make the learning curve a little gentler.

I suggest that the following content be understood clearly, especially the three major stages of the rendering pipeline.

Unity Shader Basics

Next, I suggest to go directly to understand the basics of Unity Shader, because I think this piece of knowledge is the minimum amount of knowledge that can be used to write shaders.

This is a relatively key knowledge point, and it is a skill module worthy of repeated hands-on, operation, and learning.

For example, we don’t care about how many attribute types, tags, rendering settings, and compilation instructions there are, and implement a "Hello word" first, but the implementation does not refer to simple code copying.

After doing it by hand, we can try to change different settings to achieve other effects. After repeated operations several times, we have a basic understanding of what a shader is.

Mathematical basis

For students with poor mathematical foundation, this module is very difficult to learn, especially the linear algebra and matrix parts.

For students who are really hard to chew, I suggest skipping directly and going to the next part.

In the vector part, pay special attention to the geometric and algebraic meanings of dot product and cross product, otherwise it will be difficult to understand the deformation of the formula later.

For the matrix part, you need to understand the meaning of the matrix, the type of the matrix, the most basic algorithm, and understand that the geometric meaning of the matrix lies in the transformation of data.

For more content, it is recommended to eat with the "3D Mathematical Foundation" recommended above, the effect will be better.

Basic Lighting Principles

I think this part is not so difficult, because many lighting formulas are fixed. As long as you understand the basic physics knowledge, it should not be difficult to understand. Even if you can't understand it, just remember it for now.

Among them, diffuse reflection and specular reflection are the most important part of our hands-on practice. We need to practice the different effects of several reflections in the two shaders to understand the difference between the two different shaders.

Basic Rendering Effects

The rendering effect here refers to the effect obtained by combining the basic light and texture maps and the rendering order.

Among them, the transparency test can decide whether to render the image, and the transparency mixing can get a translucent effect. This part also requires hands-on practice to figure out how to achieve the corresponding effect.

write at the end

Although there is not much introduction to the introduction of shaders throughout the article, I hope that in this way, it will be easier for everyone to accept the matter of learning shaders.

In fact, not only learning shaders, but as technicians, we should have the ability to learn quickly. The part about learning methods is also applicable to quickly mastering other skills, and I hope it can help everyone.

Original: Unity Shader - a different introductory book - know almost

Guess you like

Origin blog.csdn.net/weixin_42565127/article/details/130626007