How to change the opacity of a rectangle with slider ui

619 Views Asked by At

How to change the opacity of the rectangle on which I am using a noisy texture.

I want to change this via slider UI.

enter image description here

1

There are 1 best solutions below

0
On

Assuming that you have your noisy texture (or whatever) added to your assets: enter image description here

  1. Drag your texture (grain) into the patch editor (If it's not open, press Alt+Ctrl+P)
  2. In your material's properties, click on the arrow next to "Texture" to add it to your patch editor as well (material0)
  3. And then try to make the following patches and connections and you're done: enter image description here

The explanation of the graph:

  1. You pipe the RGBA values of your texture (grain) to a color Space patch in order to change the color mode from RGB (Red, Green, Blue values) to HSL (Hue, Saturation, Lightness)
  2. Unpack the values to a vector 3
  3. Then repack the values to a vector 4 patch (which the last one is the transparency value)
  4. Control #3 value with a slider to go from 0 to 1.
  5. Pipe to another Color Space patch which converts the color values back to original RGB
  6. Connect the the final color values of the texture to your material assigned to your rectangle.

Result: enter image description here