Page 1 of 1

Add outline/transparency to multiple meshes as a whole

PostPosted: Sun Feb 03, 2019 10:16 pm
by martin.3361
I recently got Amplify Shader Editor as I'm not that familiar with shaders and want to experiment with a node-based framework. I am trying to add tint, transparency (or more advanced effects such as dissolving, etc.) to a model.
The problem is I want to treat the model as a whole, even if it has some weapon equipped. Here is a preview of what I tried:
Image

Opaque is fine, tinted is almost ok (this is just an emission added), but transparent is obviously not what it needs to be.
Now I do understand that the model is not a single mesh. There are things behind the foremost faces which are visible. Maybe if it was a single mesh that would not be a problem.

But let's say he can equip a weapon in front of his chest. Obviously the weapon can't be a part of the mesh of the player (given that weapons can be switched). Tint, transparency or dissolve need to treat the player and the equipped weapon as a whole.

Let's see a Brawl Stars screenshot:
Image
The player's skin AND his weapon have transparency and outline. But both treat the two separate objects as a whole.

I did some research and saw that this could be achieved with additional render textures and/or manipulate the resulting 2D image. While this approach is clear to me, it doesn't suit my use case and it sounds too complex so I suggest there is an easier way, just with shaders.

My knowledge in shaders is limited but my wild guess would be writing the model and the weapon in a depth buffer and then do a secondary render pass over that buffer and treat the resulting pixels, but I am not sure.
Please assist with any suggestions. Thank you!

P.S. Also the player and the weapon may be animated, i.e. SkinnedMeshRenderers

Re: Add outline/transparency to multiple meshes as a whole

PostPosted: Mon Feb 04, 2019 12:29 pm
by Amplify_Borba
Hello, thank you for getting in touch and for your support!

Transparency can be quite complicated to deal with, especially when you start throwing other effects and conditions to the mix. An additional depth pass would be necessary to deal with the sort of overlap that you see in your current model, and this can be enabled by the following toggle:

Image

Please be aware that tweaking the settings available on the Standard shader might only take you so far, and for more specific needs we provide the Shader Templates feature that allows users to create their own custom shaders, although this requires advanced shader knowledge.

Regarding the outline, the one that we provide in ASE is per-object and limited to Forward rendering, however, it's definitely possible to develop a custom solution for an outline effect. I believe that a screen-space solution would be ideal for this type of situation, as it should provide good results regardless of the geometry used.

You can use our Post Process template for creating a post-processing shader for this type of effect.

Image

Here's an article that provides an example of how to implement a similar solution.

Re: Add outline/transparency to multiple meshes as a whole

PostPosted: Tue Feb 05, 2019 1:07 am
by martin.3361
Thank you, I will check this out and get back to you