Map a texture to always rotate to face player, always pan towards player.

I’m trying to create a water shader with some shoreline behavior. The overall effect I’m trying to pull off can be seen in this video:


at 26 seconds in, as the water comes up on the shore, you can see a thin line (not the foam hitting the shore, I already have that accomplished) coming towards the shore. I’m working on a stylized game, using cel shading and I rely on emission more than specularity for certain dynamic lighting pieces.

I already have the foam hitting the shore, by masking in a foam texture to the diffuse and emissive color channels, using the depth-fade function as the alpha. But I to get the smaller, thinner waves, I think I’ll need to use some form of subtractive depth fade to add in the thin lines, so that they align with the shore. What I think I need to do is set the fade depth further out than the reach of the foam, but somehow mask the area between the shore and the edge of the depth fade, so that only a thin line of it is rendered. Is this possible? And if so, how would I do this?

Here’s what I have so far, and what I’m shooting for:


Can a mod please rename my thread to, "Depth Fade masking questions"

Use DestDepth - PixelDepth to generate your base gradient. Then you can do things like use the distance node (or simply subtract a target scalar and use absolute value) to get band gradients in any position. Multiply and/or offset and then clamp 0-1 to get each additional gradient. Add the results to the opacity so they can render and then use the same values to lerp in different colors if needed.

Bumping this as I can’t seem to find any DestDepth node in UE4. Is there an alternative way around this?


DestDepth is just called SceneDepth now, sorry about that.