1
\$\begingroup\$

I want to achieve this effect in unity when processing my spritesenter image description here before

enter image description here After

I was thinking that I could use two color pickers to tell a shader only to create a gradient if two colors share a border. That way the gradient will not bleed into the other areas of the texture.

Most of the tutorials I've seen show how to do it with 2 colour textures, but I don't know how to isolate the specific colors and borders to make a gradient when there are more than 2 colors involved. I'm still a beginner to shaders, so I don't know if there's a better way to approach this.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Could you please explain more clearly what exactly you're trying to achieve? Assume no knowledge of your project or chosen art style. (Links to relevant tutorials you've been using are also helpful). \$\endgroup\$ Commented Oct 6, 2023 at 3:21
  • \$\begingroup\$ Would it really be infeasible for your use-case to do that in an image editor? \$\endgroup\$ Commented Oct 6, 2023 at 11:57
  • \$\begingroup\$ @Philipp It can be a little cumbersome to have after effects be part of the process since I think I can accomplish most of the rest of the effects in unity. (subscription fees and exporting in AE can be a pain.) Most of the rest of the effects are also context dependent so having all control in engine would be the most ideal way to approach it I think. \$\endgroup\$ Commented Oct 7, 2023 at 10:06

1 Answer 1

1
\$\begingroup\$

It's hard to answer this question without seeing any of your actual artwork, but I'll try anyway (if you don't have any actual artwork yet, you are trying to solve this problem way too early).

It sounds like you're trying to make this way more complicated than it should be.

If your character's face is a sprite...

Character face

...just make another transparent sprite for the blush...

enter image description here

... and place it over the face.

Face with blush

For more control over the color, you would normally make the blush sprite pure white and set the color in Unity.

In this simple example, my gradient blush is covering up the 5 lines on the cheek. This can be solved by adding the lines to the gradient blush, or making them a separate sprite and placing that above the gradient blush.

On the right side of the image, the girl's hair is partially obscuring the blush on her left cheek. This would require the hair to be on a separate layer on top of the blush.

What if the character is 3D? If the character is 3D, you might be able to get away with placing a blush sprite in front of the character's cheek as long as the player can't get close enough to tell that the blush is a sprite. Otherwise, you'll need a shader with an extra texture layer to blend over the main texture.

\$\endgroup\$
3
  • \$\begingroup\$ thanks for the suggestion. the primary reasons I want to do it programmatically is to avoid having to deal with so many layers and to have some consistency between frames. sorry I cannot share the sprites, but it will be similar to the image I posted. (2d animated sprites with multiple layers for eyes, mouth, and other independent moving parts.) Further research is suggesting that creating the blush purely in a shader wouldn't be a trivial task though. \$\endgroup\$ Commented Oct 7, 2023 at 18:56
  • \$\begingroup\$ @hello So you're okay with having separate layers for the eyes, mouth, and other moving parts, but one additional layer for the blush is too much? \$\endgroup\$ Commented Oct 11, 2023 at 0:40
  • \$\begingroup\$ I'm not saying your solution is infeasible for my project, it's something I'm considering especially if it's not possible to have control programmatically. To respond, some layers are non-negotiable, but each layer makes the project file harder to navigate, lets say the sprite doesn't move too much and the sprite looks like this where the hair touches the blush, I'd need to split 2 more layers at minimum for the hair and blush. there are unique animations with multiple chars so it can add more overhead for each additional char. currently I'm trying to save layers where possible. \$\endgroup\$ Commented Oct 12, 2023 at 5:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.