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

Commit 164d7d46 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix initial visual artifacts in rain effect." into main

parents 1d1fba76 73ccc8a7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -32,5 +32,6 @@ vec4 main(float2 fragCoord) {
    half outline = smoothstep(0.1, 1.8, dY * 5.0);

    // Return the results in the R channel.
    return vec4(outline, 0., 0., 0.);
    // Also return alpha 1 avoid visual artifacts when it is used standalone.
    return vec4(outline, 0., 0., 1.);
}
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.google.android.wallpaper.weathereffects.graphics.rain

import android.graphics.BitmapShader
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RenderEffect
import android.graphics.Shader
@@ -26,6 +27,7 @@ import com.google.android.wallpaper.weathereffects.graphics.FrameBuffer
import com.google.android.wallpaper.weathereffects.graphics.WeatherEffect
import com.google.android.wallpaper.weathereffects.graphics.utils.GraphicsUtils
import com.google.android.wallpaper.weathereffects.graphics.utils.ImageCrop
import com.google.android.wallpaper.weathereffects.graphics.utils.SolidColorShader
import java.util.concurrent.Executor
import kotlin.random.Random

@@ -177,6 +179,8 @@ class RainEffect(
    }

    private fun prepareColorGrading() {
        // Initialize the buffer with black, so that we don't ever draw garbage buffer.
        rainConfig.glassRainShader.setInputShader("texture", SolidColorShader(Color.BLACK))
        rainConfig.colorGradingShader.setInputShader("texture", rainConfig.glassRainShader)
        rainConfig.lut?.let {
            rainConfig.colorGradingShader.setInputShader(
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.wallpaper.weathereffects.graphics.utils

import android.graphics.RuntimeShader

/** Simply renders a solid color. */
class SolidColorShader(color: Int) : RuntimeShader(SHADER) {
    // language=AGSL
    private companion object {
        private const val SHADER =
            """
                layout(color) uniform vec4 in_color;
                vec4 main(vec2 p) {
                    return in_color;
                }
            """
    }

    init {
        setColorUniform("in_color", color)
    }
}