Chicken shader2: L2 is based on BlinnPhong fake environment reflection, rusty material

Fake environment reflection material (stainless steel material)

Put the final picture first:
insert image description here

Handle highlights:
insert image description here
insert image description here

insert image description here

  • Here is phong model not blinnphong.
  • Apply the dot product of the reflection direction of the observation direction and the light direction to calculate the highlight, and then remap the value range to [0,1] to prepare for the subsequent sampling texture. The range of texture coordinates is [0,1], and then multiply by a coefficient to control the result of the entire texture sampling, which should be the intensity.

Then there is the formal phong model:
insert image description here
insert image description here

Add the above two parts together to get the final result:
insert image description here

rusty material

Put the final effect first:
insert image description here

  • The principle is actually to use the noise map as a mask, which is divided into background color and rusty color, and the masked part is the rusty color. To use a mask is to use the lerp function.
  • Then add the effect of Fresnel, the effect is not very obvious, you should still be able to see that the circle around the material ball is obviously brighter.

First the Fresnel term:
insert image description here

  • The control coefficient and color of the Fresnel term are added, so I won’t go into details.

Then there is the blinnphong item:
insert image description here

  • The BlinnPhong item uses the half-way vector (the intermediate vector between the light direction and the viewing direction, that is, the two normalized vectors after addition) and the result of the normal vector dot product.
  • The BlinnPhong item calculates the highlight item, that is, the specular reflection light, which is related to the viewing direction.

Then there is the Lambert term:
insert image description here

  • The normal vector and the light direction dot product, the Lambert term is used to calculate the diffuse lighting, that is, the ambient light, and has nothing to do with the viewing direction.

Then the mask item:
insert image description here
insert image description here

  • Control the uv coordinates to sample the noise texture, add a threshold to layer the sampled results, return 0 if it is higher than the threshold, and return 1 if it is lower than the threshold, so that the contrast between black and white is more obvious.
  • Desaturate: Outputs a desaturated version of [Col]. [Des] determines how to desaturate. A value of 1 indicates full desaturation, 0.5 indicates half desaturation, and 0 indicates no desaturation.

Final operation:
insert image description here

  • add is the result of the addition of the highlight item, the Lambert item and the Fresnel item, as the layer a of the lerp function, which is the background layer.
  • The result of add is multiplied by a highlight color, which is used as the b layer of the lerp function, which is the rust layer.
  • The mask item is used as the t layer of lerp, that is, the mask.

Complete Lianliankan:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_43789369/article/details/130499154