Decoding unity in CG writing shader series 6?? Diffuse reflection

Source: Internet
Author: User

Transfer from http://www.itnose.net/detail/6116553.html

If the content of the previous series of articles is too lengthy and lack of interest, because of time reasons before the mixed part has not been finished, and so on, and then add, now began on the reflection of the content.

Refraction and reflection

In the physical world, the reflection and refraction of light are often at the same time, the light source from the vacuum or air into a material, light in the material at the same time the refraction, the degree of refraction and the refractive index of each medium, so that the route of light to deviate from the original route;

And then if the light passes through the surface of different media, it bounces back like a table tennis, and we can see things in our eyes because things can reflect light, and if a substance can't reflect light, or there's no light, we can't see things. Also for different materials, the higher the light passing, the less obvious the reflection, such as glass (but the glass will also have a certain reflection, otherwise we can not see the glass, in fact we see); The lower the light passing, the more obvious the reflection, such as the water, we could see the fish in the waters (light from water to fish skin, The skin of the fish has a diffuse reflex), and you can see your own reflection (specular reflection on the surface of the water).

Specular reflection and diffuse reflection

So the difference between specular reflection and diffuse reflection is that the surface of the object is bouncing back, the surface of the degree of flatness, the more flat closer to the mirror reflection, the more coarse is diffuse reflection. The surface of most of the things we see in real life are rough, so they are diffuse. Be sure to go back and review the specular reflection and refraction in our physical science before discussing diffuse reflection, because diffuse reflection can be broken down into countless tiny specular reflections (like a circle can be seen as a regular polygon of countless edges), after all, the game world is also to simulate the physical world, the game engine must conform to the physical laws. Draw a picture recall: above this picture I draw is not very good, I need to explain the incident light and the plane angle is the angle of incidence, reflected light and the plane angle is the reflection angle, the angle of incidence is always equal to the reflection angle, the picture is not painted well. Similarly to the uneven surface of the media, we can be infinitely subdivided into countless plane of law, for each surface of the reflection of the point, we can do a tangent along the current point and the surface of the object tangent to the point, to get a plane. So the law of specular reflection can be applied directly to diffuse reflection. To indicate: We analyze the reflection of a certain point of the surface of medium B at this point to do a tangent to the surface tangent to this point, the same position of the law plane, normal, angle of incidence, reflection angle good review here, in the previous series we have lifted to the normal and FA plane, We will see in our three-dimensional object of the medium B, then the black curve part of its surface, then the surface of each point of the normal direction is not the same, because each point does cut tangent to the surface of the plane is not necessarily parallel, So in the CG in the mesh information passed in each vertex has a normal value, that is, the normal vector. The normal vector is the unit vector of the tangent point in our normals toward the direction of medium a.

Decoding unity in CG writing shader series 6?? Diffuse reflection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.