Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e374ba3 authored by Yein Jo's avatar Yein Jo
Browse files

Add intensity uniform param.

Bug: 325090421
Test: m WeatherEffectsGraphicsLib
Flag: NA
Change-Id: I9e6a39ca15a4ba4705544ae0c78ee65e34a5bce2
parent f2c76431
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ uniform half timeBackground;
uniform half screenAspectRatio;
uniform half2 screenSize;
uniform half pixelDensity;
uniform half intensity;

#include "shaders/constants.agsl"
#include "shaders/utils.agsl"
@@ -59,11 +60,11 @@ vec4 main(float2 fragCoord) {

    float dither = 1. - triangleNoise(fragCoord * pixelDensity) * 0.161;

    color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.8 * dither * bgdFog);
    color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.8 * dither * bgdFog * intensity);
    // Add the foreground. Any effect from here will be in front of the subject.
    color.rgb = normalBlend(color.rgb, colorForeground.rgb, colorForeground.a);
    // foreground fog.
    color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.5 * frontFog);
    color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.5 * frontFog * intensity);

    return color;
}
+5 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ uniform float2 uvScaleBgd;
uniform float time;
uniform float screenAspectRatio;
uniform float2 screenSize;
uniform half intensity;

#include "shaders/constants.agsl"
#include "shaders/utils.agsl"
@@ -66,7 +67,7 @@ vec4 main(float2 fragCoord) {
         screenAspectRatio,
         time,
         /* Grid size = */ vec2(4.0, 2.0),
         /* rain intensity = */ 0.8);
         intensity);
    float dropMask = drippingRain.dropMask;
    float droppletsMask = drippingRain.droppletsMask;
    float trailMask = drippingRain.trailMask;
@@ -79,7 +80,7 @@ vec4 main(float2 fragCoord) {
          screenAspectRatio,
          time * 1.267,
          /* Grid size = */ vec2(3.0, 1.0),
          /* rain intensity = */ 0.6);
          intensity);
    dropMask = max(drippingRain.dropMask, dropMask);
    droppletsMask = max(drippingRain.droppletsMask, droppletsMask);
    trailMask = max(drippingRain.trailMask, trailMask);
@@ -139,7 +140,7 @@ vec4 main(float2 fragCoord) {
          screenAspectRatio,
          time * 18.,
          /* Grid size = */ vec2(30.0, 4.0),
          /* rain intensity = */ rainIntensity);
          intensity);

    color.rgb = mix(color.rgb, highlightColor.rgb, rainVisibility * rain.dropMask);

@@ -152,7 +153,7 @@ vec4 main(float2 fragCoord) {
          screenAspectRatio,
          time * 27.,
          /* Grid size = */ vec2(8.0, 3.0),
          /* rain intensity = */ rainIntensity);
          intensity);

    // The rain that is closer, make it less visible
    color.rgb = mix(color.rgb, highlightColor.rgb, 0.7 * rainVisibility * rain.dropMask);
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ const mat2 rot45 = mat2(
    -0.7071067812, 0.7071067812 // second column.
);

uniform half intensity;

/**
 * Generates snow flakes.
 *
@@ -74,6 +76,16 @@ Snow generateSnow(
    vec2 cellUv = fract(gridUv) - 0.5;
    cellUv.y *= -1.;

   /*
    * Disable snow flakes with some probabilty. This is done by 1) assigning a random intensity
    * value to the cell 2) then compare it with the given intensity.
    */
    half cellIntensity = idGenerator(floor(vec2(cellId * 856.16, 272.2)));
    if (cellIntensity < 1. - intensity) {
        // Remove snow flakes by seeting flake mask to 0.
        return Snow(/* flakeMask= */ 0, cellUv);
    }

    /* Cell-id-based variations. */
    // Adjust time based on columnId.
    // Adjusts scale of each snow flake (higher is smaller).
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

uniform shader foreground;
uniform float2 imageSize;
uniform half intensity;

#include "shaders/simplex2d.agsl"
#include "shaders/utils.agsl"
@@ -27,7 +28,7 @@ float random(vec2 uv) {
vec4 main(float2 fragCoord) {
    // fragCoord should be already the adjusted UVs to have the expected rect of the image.
    float variation = 0.5 + 0.5 * simplex2d(25. * fragCoord / imageSize.xx);
    float distance = 8. * variation;
    float distance = 8. * variation * intensity;
    float aN = foreground.eval(fragCoord + vec2(0., distance)).a;
    float aS = foreground.eval(fragCoord + vec2(0., -distance)).a;
    float dY = (aN - aS) * 0.5;
+8 −6
Original line number Diff line number Diff line
@@ -55,20 +55,22 @@ vec4 main(float2 fragCoord) {

    // Get color of the background texture.
    color.rgb = mix(colorBackground.rgb, glassTint.rgb, frostedGlassIntensity);
    for (float i = 9.; i > 2.; i--) {
    for (half i = 9.; i > 2.; i--) {
        // Generate snow behind the subject.
        // Normalized layer index.
        half idx = (i - 2.) / (9. - 2.);
        Snow snow = generateSnow(
              uv,
              screenAspectRatio,
              time * 1.25,
              /* Grid size = */ vec2(2.1, 1.4),
              time * mix(1.25, 5., idx),
              /* Grid size = */ vec2(mix(3.0, 6.0, idx), mix(1.0, 3.0, idx)),
              /* layer number = */ i);

        color.rgb = mix(color.rgb, snowColor.rgb, snowOpacity * snow.flakeMask);
    }

    // Add the foreground. Any effect from here will be in front of the subject.
    color.rgb = mix(color.rgb, colorForeground.rgb, colorForeground.a);
    color.rgb = normalBlend(color.rgb, colorForeground.rgb, colorForeground.a);

    // Add accumulated snow.
    vec2 accSnow = accumulatedSnow.eval(adjustedUvForeground).rg;
@@ -76,13 +78,13 @@ vec4 main(float2 fragCoord) {
    float snowTexture = smoothstep(0.2, 0.7, accSnow.g);
    color.rgb = mix(color.rgb, vec3(0.95), 0.98 * snowLayer * (0.05 + 0.95 * snowTexture));

    for (float i = 2.; i >= 0.; i--) {
    for (half i = 2.; i >= 0.; i--) {
        // Generate snow behind the subject.
        Snow snow = generateSnow(
              uv,
              screenAspectRatio,
              time * 1.25,
              /* Grid size = */ vec2(2.1, 1.4),
              /* Grid size = */ vec2(i + 1., 1.4),
              /* layer number = */ i);

        color.rgb = mix(color.rgb, snowColor.rgb, snowOpacity * snow.flakeMask);
Loading