- Home /
how to invert Alpha channel at runtime?
I need a script that inverts the alpha channel of a texture when I trigger it.
I have a energy pipeline on the floor. I use for this pipeline a transparent cutout shader. when I activate a button the cutout slider will be animated and the gradient alpha will make the pipeline texture visible from point A going to point B.(looks like a river of energy that has started to flow to point B)
now if I deaktivate the button the cutout slider will be animated backwards and now it looks like the energy is running back from point B to point A... but I want that it looks like that no energy is comming from point A to point B. so I need to invert the alpha befor it animates the cutout slider.
please help. thx.
Answer by Wolfram · Feb 03, 2013 at 07:10 PM
There are two other, simpler possibilities, besides messing with the texture's alpha directly:
Create another texture in your favorite image manipulation program that already has an inverted alpha, and then simply switch between these two textures. This is probably the best solution if you only have one or few source textures.
Adapt the shader you are using so that it inverts the alpha when reading from the texture.
yes the first solution is really the best solution. thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220613092101im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
Inverting all light on trigger (2D)? 0 Answers
help with fade/cutout skybox shader 0 Answers
How do I switch control values? 1 Answer
Make one trigger enter true for overlapping triggers 0 Answers