- Home /
displace each vertex of an object with different amounts using shader?
Hi I'm very new to creating shaders
I have currently an outline shader that extrudes by a specific amount
v.vertex.xyz += v.normal.xyz * _ExtrudeAmount *0.01;
Is it possible to make the _ExtrudeAmount value random between 0 and 1 so that the extruded amount of each vertex is different making the outline look like waves?
Answer by Remy_Unity · Jan 30, 2018 at 08:59 AM
Making random in shader is quite computational heavy, but you can have some kind of random : https://answers.unity.com/questions/399751/randomity-in-cg-shaders-beginner.html
If you want wavy lines, you could use for exemple:
v.vertex.xyz += v.normal.xyz * _ExtrudeAmount *0.01 * sin( v.vertex.y * 5 );
This should make vertical waves.
Your answer

Follow this Question
Related Questions
Set PSIZE in Surface shader 0 Answers
Image effect shader not running 1 Answer
Sharing code between shader and c# - how? 3 Answers
Change color of a 3D object based on the vertex' y-value 0 Answers