Here's the last post to end this ShaderGraph month, all graphs are attached!
这是结束这个月关于ShaderGraph的最后一篇文章,所有图表都附上了!
These are a little bit more complicated, I would've liked to do more, but without a double pass option I can't make my Outline shaders (Direcitonal Rim Light, Aura Outline) and the Foam Edge/Intersection effects are also not possible from the nodes given.
But I did manage to convert these other popular shader effects :)
The difference with the Shader Graph version is that there is no different color for the fake surface and the side foam, because Zwrite On is not an option from graphs, but it still looks pretty cool.
Let's get started.
First part is getting the right positioning to keep the liquid level with the world, while it's in the same position within the bottle.
Plug the result into the alpha, and set the Blend mode to Alpha, Turn on Two Sided, and create a Vector`1 for the AlphaClipThreshold to work.
Now it only shows the filled part of the object.
Creating a false surface is done by using the Is Front Face Node, as the name suggests, this returns true when it's a front face and false when its a backface, with a Branch node, you can have a different color for these two cases. Multiply the branch result with the step and you've got a fake filling!
Now it just needs to wobble!
The script that you add to the object with this shader will give it 2 values, _WobbleX, and _WobbleZ, these two values drive how much rotation happens. First they need to be added to the properties, so don't forget to do that!
The code version uses this rotation function, Shader Graph has a Rotate About Axis Node, it doesn't seem to work exactly the same, but we can sort of create a rotation with this.
Rotate the object by 90 degrees and multiply by the WobbleZ, and add the object position multplied by WobbleX to add the wobble rotation to the Local Position.