I found this old thread on how to create noise gradients, but it doesn’t properly fade to transparent which creates a hard border effect. I was wondering if it was possible to have only the gradient be noisy, not the transparency in the end.
Here is what I tried so far:
.black-bar {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100px;
background-size: cover;
background-position: center;
background-repeat: repeat;
stop-color: black;
background-image: linear-gradient(to bottom,
rgba(0, 0, 0, 1) 0%,
rgba(0, 0, 0, 1) 50%,
rgba(0, 0, 0, 0) 100%),
url('/noise.svg');
z-index: -1;
}
<svg viewBox='0 0 250 250' xmlns='http://www.w3.org/2000/svg'>
<filter id='noiseFilter'>
<feTurbulence
type='fractalNoise'
baseFrequency='5'
numOctaves='3'
stitchTiles='stitch'/>
</filter>
<rect width='100%' height='100%' filter='url(#noiseFilter)'/>
</svg>
And here is the border effect I’m talking about:
Hard border effect I don’t want
Noisy gradient I’m looking for (Mockup created in Photoshop)
2
Answers
I found the solution. Inverting the noise while fading itself to transparent while applying it after the gradient seemed to create the transition I'm looking for. Here is the scss
And here is the final result
I don’t get the requirements 100%, but is it something like this. The SVG has a rectangle with both a filter and a mask. The mask creates the gradient. Therefore the noise filter is not visible in the transparent part of the rectangle. The part I don’t get is the black color. Should the gradient cover the black?
Second attempt
Maybe this is more like it. The filter is now part of the mask. And the mask is going from white to black with a opaque (.5) part in the middle. The opaque part will make the filter visible. The mask is applied to a black rectangle making the top black and the bottom transparent.
I made a SVG for the content of the page, so it looks more like your mock-up.
This is the SVG that is used at a background image in the CSS: