Help with Custom Shader: Gradient Opacity Based on UV Input

Hi everyone,

I’m trying to build a custom shader in Unreal that takes five inputs:

  1. Color
  2. Opacity_X
  3. Opacity_Y
  4. In
  5. Out

The idea is to simulate how light passes through a solution and gradually loses opacity. Here’s how I want the opacity to behave along the Y axis of the UVs:

  • From UV (0,0) to UV (0, In): use Opacity_X (constant).
  • From UV (0, In) to UV (0, Out): blend/transition from Opacity_X to Opacity_Y.
  • From UV (0, Out) to UV (0,1): use Opacity_Y (constant).

The final output color should reflect this opacity gradient. Any suggestions on how to approach this using the Material Editor or HLSL would be really appreciated!

Thanks in advance!

Just checked and chat GPT actually gives good advice for it, and math that seems to be working.
One of those well described common problems, so it is not in “made up stuff” zone yet.
Just ask it for explaining and giving solution for problem.
I could copy past it here, but you get better quality when you ask it yourself, it can give additional hints.

Yes, thank you. Indeed, ChatGPT gave me exactly what I needed.

1 Like