Shader can make you fat? Bloated fat effect!
The effect
implementation
The shape of the model is usually surrounded by triangles, and each vertex usually has a normal information.
So all we have to do is add a little bit more distance to the position of each vertex along the normal line.
position.xyz + v_normal * fatFactor
Copy the code
So how do you incorporate this effect in CCC 3D?
Find the model’s material and see what effect is used by default (typically builtin-standard.effect).
Make a copy of builtin-standard.effect and start writing it.
Find the normal vector and compute the vertex coordinates.
Plus the displacement in the normal direction.
return cc_matProj * (cc_matView * matWorld) * vec4(In.position.xyz + v_normal*0.05, In.position.w);
Copy the code
Finally, choose builtin-standard-fat.effect to see the effect.
Of course, you can also define a fatFactor.
uniform lamyoung_com {
float fatFactor;
};
//In.position.xyz + v_normal * fatFactor
Copy the code
Externally control the obesity factor, and you get the schematic.
this.modelComponent.getMaterial(0).setProperty('fatFactor'.0.1 * slider.progress);
Copy the code
summary
Normal vector! Swell! Shader!
Cocos Creator 3D V1.1.2 for shader Expansion Effect (FAT) Welcome to share with friends around!
Are things difficult or easy in the world? For it, the sufferers are easy; If you do not, it is difficult to make things easy. Is it difficult for people to learn? Learn, then the sufferers are easy; Do not learn, then easy is difficult.
The original link