In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Matcap Shader dynamic lighting and machine position and reflection is like, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Preface
Traditional Matcap cannot respond to changes in light source and camera position-that is, it cannot use dynamic lighting, machine position, and reflection
In the following picture, the camera rotates, but no matter which direction the model is exposed to the same light-no backlight!
This time, let's discuss how to solve this problem.
By the way, what we're going to do today doesn't need code.
Cubemap?
When it comes to picture sampling to simulate lighting, there is a more famous method outside of Matcap, which is Cubemap (as shown in the following figure)
The advantage of Cubemap is obvious, it can respond to rotation, so it is the preferred method to calculate static reflection.
Therefore, some friends have proposed to use Cubemap instead of Matcap, which is a good idea and worthy of praise.
But Cubemap has its own flaws:
Can only respond to camera changes, not light changes
It is difficult to draw Cubemap. By contrast, Matcap drawing is very simple and intuitive.
The definition is lower than Matcap at the same resolution, and takes up more memory at high resolution.
If generated in real time, the cost is very high (for example, Realtime Reflection Probe)
So let's talk about how to use Matcap to solve the problem of lighting and rotation. As for reflection, we will also use Cubemap, but Cubemap sampling will not be calculated in Matcap Shader.
Real-time Matcap sampling map
Yes, it's a simple way to use RenderTexture to render a Matcap sample map in real time.
The sphere can use any other Shader, such as the official Standard Shader
The camera that saves the picture only renders the sphere through CullingMask.
You may wonder, why not use Standard Shader entirely? isn't it less efficient to render RenderTexture with a camera?
In fact, this is not the case for the following reasons:
In a formal project, there will be a large number of objects to be rendered in a frame (for example, 100). If there are two real times, if all Standard Shader is used and Instancing is not considered, then Draw Call will be at least 200 or more, and the pressure of a single rendering will be much greater than that of Matcap; while the method of using RenderTexture only needs one Standard+100 Matcap, which is much more efficient.
If you need multiple materials, you can refer to "Matcap Shader detailed explanation [4]-Multi-materials and mixed materials", rendering two or three Matcap, you can combine the various materials needed in the scene. And multiple Matcap can also be rendered by one DC, so it's not complicated, so we don't need to expand it.
RenderTexture's camera is only used to render a sphere, so it is still very efficient, far more efficient than RealTime Reflection Probe.
Let's take a look at the effect achieved (dual light source, in addition to the main light source, there is also a reflection):
Dynamic position (camera rotation)
As shown in the figure, when the camera rotates, the lower right corner of the Scene view can be seen, and the Matcap map will be updated in real time, so there will be a backlight effect around the back of the character in the Game view.
It can be compared with the dynamic picture at the beginning of the article.
Dynamic illumination
As shown in the figure, dynamically adjust the rotation direction of the light (in the Scene view) to reflect the rendering results in real time.
Reflection
It is true that Matcap can use Cubemap to achieve reflection, but in order to further improve efficiency, it is not necessary for Cubemap to sample in Matcap, but to render directly to RenderTexture.
As shown in the following figure, the lower right corner of Scene can be seen. Dynamic Matcap not only has a good reflection result, but also has dynamic light and shade, and you can turn it as you like. The result can be seen in the Game view.
Note: the Cubemap used here is the example shown at the beginning of the article, which is directly used for environmental reflection in the lighting settings.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.