Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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)


Product Version: Not Selected
more ▼

asked Jun 12 '14 at 01:07 PM in Rendering

avatar image

8 2 3 7

avatar image Lovecraft_K ♦♦ STAFF Jun 12 '14 at 04:03 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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** and **pt.2 here**. 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.

alt text

alt text

Thank You

Eric Ketchum

2dmat.jpg (171.3 kB)
inlevel.jpg (74.1 kB)
more ▼

answered Jun 12 '14 at 08:08 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.8k 702 260 736

avatar image Skas Jun 15 '14 at 12:48 PM

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

avatar image KillerSneak Aug 26 '15 at 09:10 AM

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?

avatar image Lovecraft_K ♦♦ STAFF Aug 26 '15 at 05:33 PM

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

avatar image PatTheDemon Jan 10 '16 at 05:35 AM

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. :(

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?

avatar image Lovecraft_K ♦♦ STAFF Jan 14 '16 at 08:32 PM

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

avatar image Lovecraft_K ♦♦ STAFF Jan 14 '16 at 09:08 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question