Thursday, September 22, 2022
HomeGame Developmentunity - Learn how to make a shader which alpha blends in...

unity – Learn how to make a shader which alpha blends in opposition to solely itself, and is opaque in any other case?


I can consider a means to do that in two passes with a floating level render goal initialized to black:

Cross 1: use additive mixing into the render goal with depth testing/writing off; write your color to the RGB channel and 1 to the alpha channel.

Cross 2: learn the earlier contents of the render goal, and divide the RGB values by the alpha worth, outputting the consequence as an opaque color (no mixing).

For pixels written to solely as soon as, that is principally a no-op and simply offers the unique color you wrote. For pixels written to a number of instances, this offers the common color, with every write given an equal weighting. That matches your 1, 0.5, 0.33, 0.25 weight sequence.

This second cross could be the one which writes into your unique scene, with depth testing/writing enabled to clip out any occluded elements of this object.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments