how to apply a shader to a group of nodes ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nonomiyo

Hi !

I want to apply an outline shader to a character that I’ll animate using cutout animation.
The problem here is that I have an outline for each body part where I’d like only 1 outline for the whole character :

> SCREENSHOT HERE <

I tried having the shader on the parent node / putting the body parts in a “character” scene, but it’s not working…

(it’s Godot 3.1 alpha 2)
Thanks !

:bust_in_silhouette: Reply From: eons

You do not apply a shader to a node, you assign a shader to a material, simply create a material resource that uses your shader, one material for each different shader parameters (because resources are shared, you can also mark as local in the scene files).

Then just use that material on the elements that need it.

thanks for your answer Eons.

My formulation was wrong and I’m not sure you understood my question. Even if I assign the outline shader to a material used by every parts of the body, they still would be outlined individually and not as a whole.

Please have a look at the screenshot link I posted to have a clear idea of my problem (and sorry if you did answer this question but I didn’t understand)

nonomiyo | 2018-11-25 21:26

Oh, right, I have missed that part.

in that case you may have to draw a viewport (ViewportTexture needs to be set as local or will fail).
Or use a BackbufferCopy node and apply the shader over there (this may need to use a screen uv and texture in the shader).

eons | 2018-11-26 01:05

thanks, knowing where to dig is a great timesaver, I’ll look into viewports ! :smiley:

nonomiyo | 2018-11-26 11:05

:bust_in_silhouette: Reply From: nonomiyo

epilogue :

Ok, so I did my best to understand how backbuffer copies and viewports work and while I was (reaally) struggling, I came across a way to solve this that is pretty easy (not sure if it’s efficient though) :

  • I have my character with separate parts in a scene called “character”. On each part I checked the Material setting “use parent material”.

  • Then in the main scene, I have 2 instances of the “character” scene, one below with only the outline shader assigned, one on top without any shader. Voilà ! :slight_smile:

1 Like