How do I apply a Shader to AnimatedSprite3d

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

I want to take my Animated Sprite 3d and apply an outline shader to it.

However, this appears to be extremely difficult. Any shader I use will ignore any data about the animated sprite or its settings. It seems as if I would have to manually create the animation through the shader… is this right?

Have you tried AnimatedTexture?

jackathouse | 2021-09-01 01:35

Hi, I don’t know if you figured it out but I’m also looking for a way to apply shaders to 3D animated sprites

lucas_bl | 2022-02-08 02:22

:bust_in_silhouette: Reply From: Juxxec

I know this is an old post, but I needed to do the same thing in my game, so I did a little research and managed to get shaders working.

My solution is for Godot 3.5.2.

First you need to create the following scene:

Sprite3D
`-- Viewport
    `--  AnimatedSprite

Configure the Viewport to be the dimentions of one frame of your Animated Sprite. Set V Flip and Transparent BG to true.

Now create your animations in the AnimatedSprite node. You need to apply your shaders here. Just add a Material with the shader you want.

Finally go to the Sprite3D and for texture select the New Viewport Texture option. For the Viewport property select the Viewport in your tree that has the AnimatedSprite and you are done!

Here is an example. I added an outline to my AnimatedSprite.

enter image description here

While this is a valid answer, the additional rendering due to the layer computation will slow down the render step and may not be appropriate for low end mobile devices.

(When I had to solve this problem before, I ended up faking an outline shader by making silhouette sprites and placed it behind the target sprite)

BAE | 2023-04-05 00:12

I was thinking of doing the same thing. My game won’t run on mobile though so it should be fine for Desktop

Juxxec | 2023-04-05 06:13