Any advice for 2D sprite shading?

Hey there,

Ive just recently picked up UE4 and have figured out how to do a 2D Sprite side scroller.

Ive been wondering if it were possible to perform shader effects on sprites.

(Specifically I want to be able to create a flash light effect, where the player moves his flash light around the screen, changing the shading of the background)

Thanks!

Hi Skas -

I want to clarify, are you using the Paper2D plugin from the Experimental or are you following the example of Tappy Chicken for a 2D sprite game? I want to clarify before I attempt to answer.

I am working on an example for the Tappy Chicken method and will post as soon as I get it screenshot.

Thank You

Eric Ketchum

HI Skas -

Ok, since you are working with 2D sprites lighting is not really a great solution, but you can adjust the materials of your objects themselves. First I would suggest you take a moment and look at these tutorials from our Lead Technical Artist Alan Willard, [pt.1 here][1] and [pt.2 here][2]. I am using his Sphere Masking technique to function as a Lerp’s Alpha to switch between, in my test case, black and my Sprite background Texture. This should get you started on implementing the effect. You would just need to hook up the setting of the Scalar, Vector, and Location variables in your Character’s Blueprint.

Thank You

Eric Ketchum

Thanks Eric :smiley: (I refrained myself from calling you Ash)

I’m sorry to open a old topic like this, but would it be possible to add this to a moving character and make it so that the background will change in the screenshot above?

Hi KillerSneak -

Yes,but any background sprite assets you place behind the moving character would need the Sphere Mask setup in the material. So, you would probably want to turn that setup into a Material Function and then place that function in all the Background materials. If you are using a sprite, Paper2D project you can place the material function in the Base Default Sprite Material and then all the Material Instances derived from it will use that function as well.

Thank You

Eric Ketchum

So I followed everything above(tutorials, advice, etc.), however, I can not get the sphere mask to work in 2D correctly. We added the material function to all of sprite materials, and the masking sphere works so long as it is attached to the orb created in the tutorial videos, but this isn’t what we need. :frowning:

We are trying to parent the masking sphere to the paper2d character’s capsule component using the exact same blueprints from part 2 of the videos. We couldn’t get it to work the same. It would reveal the Character, but nothing else. We tried parenting the masking sphere to the the orb then having the orb set to the character’s location, but this also did not work.

Can you please hold our hands and walk us through this?

Hi Pat -

Before I do a walk through for you, try offsetting the sphere’s location in the Y Axis by adding or subtracting some from your location. With Sprites there is usually some depth in 3D space between certain things and that Y depth value may not be translated to influence other objects. While you try that I will work up an example for you.

Thank You

Eric Ketchum

Here is the Test Project with the Setup enabled. There are a few gotcha moments that can happen. When you are looking into it, make sure to look at the base materials for the Location Based Opacity Settings (I purposefully copied and re-assigned all materials into the Content so I am not using the Base/Default Paper2D Materials.) Also make sure to look at both the Event Graph and the Construction Script of the Player Character.

Let me know if you still have any questions.

Eric Ketchum

Test Project 4.10.2