Loading packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/ShaderUtilLibrary.kt +160 −157 Original line number Diff line number Diff line Loading @@ -15,10 +15,9 @@ */ package com.android.systemui.surfaceeffects.shaderutil /** A common utility functions that are used for computing shaders. */ class ShaderUtilLibrary { /** Common utility functions that are used for computing shaders. */ object ShaderUtilLibrary { // language=AGSL companion object { const val SHADER_LIB = """ float triangleNoise(vec2 n) { Loading Loading @@ -168,10 +167,14 @@ class ShaderUtilLibrary { // Octave = 4 // Divide each coefficient by 3 to produce more grainy noise. half simplex3d_fractal(vec3 mat) { return 0.675 * simplex3d(mat * rot1) + 0.225 * simplex3d(2.0 * mat * rot2) + 0.075 * simplex3d(4.0 * mat * rot3) + 0.025 * simplex3d(8.0 * mat); half simplex3d_fractal(vec3 p) { return 0.675 * simplex3d(p * rot1) + 0.225 * simplex3d(2.0 * p * rot2) + 0.075 * simplex3d(4.0 * p * rot3) + 0.025 * simplex3d(8.0 * p); } """ // Screen blend vec3 screen(vec3 dest, vec3 src) { return dest + src - dest * src; } """ } packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseShader.kt +14 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : uniform float in_aspectRatio; uniform float in_opacity; uniform float in_pixelDensity; uniform float in_inverseLuma; layout(color) uniform vec4 in_color; layout(color) uniform vec4 in_backgroundColor; """ Loading @@ -47,7 +48,7 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : uv.x *= in_aspectRatio; vec3 noiseP = vec3(uv + in_noiseMove.xy, in_noiseMove.z) * in_gridNum; float luma = simplex3d(noiseP) * in_opacity; float luma = abs(in_inverseLuma - simplex3d(noiseP)) * in_opacity; vec3 mask = maskLuminosity(in_color.rgb, luma); vec3 color = in_backgroundColor.rgb + mask * 0.6; Loading @@ -69,7 +70,7 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : uv.x *= in_aspectRatio; vec3 noiseP = vec3(uv + in_noiseMove.xy, in_noiseMove.z) * in_gridNum; float luma = simplex3d_fractal(noiseP) * in_opacity; float luma = abs(in_inverseLuma - simplex3d_fractal(noiseP)) * in_opacity; vec3 mask = maskLuminosity(in_color.rgb, luma); vec3 color = in_backgroundColor.rgb + mask * 0.6; Loading Loading @@ -123,6 +124,17 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : setFloatUniform("in_aspectRatio", width / max(height, 0.001f)) } /** * Sets whether to inverse the luminosity of the noise. * * By default noise will be used as a luma matte as is. This means that you will see color in * the brighter area. If you want to invert it, meaning blend color onto the darker side, set to * true. */ fun setInverseNoiseLuminosity(inverse: Boolean) { setFloatUniform("in_inverseLuma", if (inverse) 1f else 0f) } /** Current noise movements in x, y, and z axes. */ var noiseOffsetX: Float = 0f private set Loading Loading
packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/ShaderUtilLibrary.kt +160 −157 Original line number Diff line number Diff line Loading @@ -15,10 +15,9 @@ */ package com.android.systemui.surfaceeffects.shaderutil /** A common utility functions that are used for computing shaders. */ class ShaderUtilLibrary { /** Common utility functions that are used for computing shaders. */ object ShaderUtilLibrary { // language=AGSL companion object { const val SHADER_LIB = """ float triangleNoise(vec2 n) { Loading Loading @@ -168,10 +167,14 @@ class ShaderUtilLibrary { // Octave = 4 // Divide each coefficient by 3 to produce more grainy noise. half simplex3d_fractal(vec3 mat) { return 0.675 * simplex3d(mat * rot1) + 0.225 * simplex3d(2.0 * mat * rot2) + 0.075 * simplex3d(4.0 * mat * rot3) + 0.025 * simplex3d(8.0 * mat); half simplex3d_fractal(vec3 p) { return 0.675 * simplex3d(p * rot1) + 0.225 * simplex3d(2.0 * p * rot2) + 0.075 * simplex3d(4.0 * p * rot3) + 0.025 * simplex3d(8.0 * p); } """ // Screen blend vec3 screen(vec3 dest, vec3 src) { return dest + src - dest * src; } """ }
packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseShader.kt +14 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : uniform float in_aspectRatio; uniform float in_opacity; uniform float in_pixelDensity; uniform float in_inverseLuma; layout(color) uniform vec4 in_color; layout(color) uniform vec4 in_backgroundColor; """ Loading @@ -47,7 +48,7 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : uv.x *= in_aspectRatio; vec3 noiseP = vec3(uv + in_noiseMove.xy, in_noiseMove.z) * in_gridNum; float luma = simplex3d(noiseP) * in_opacity; float luma = abs(in_inverseLuma - simplex3d(noiseP)) * in_opacity; vec3 mask = maskLuminosity(in_color.rgb, luma); vec3 color = in_backgroundColor.rgb + mask * 0.6; Loading @@ -69,7 +70,7 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : uv.x *= in_aspectRatio; vec3 noiseP = vec3(uv + in_noiseMove.xy, in_noiseMove.z) * in_gridNum; float luma = simplex3d_fractal(noiseP) * in_opacity; float luma = abs(in_inverseLuma - simplex3d_fractal(noiseP)) * in_opacity; vec3 mask = maskLuminosity(in_color.rgb, luma); vec3 color = in_backgroundColor.rgb + mask * 0.6; Loading Loading @@ -123,6 +124,17 @@ class TurbulenceNoiseShader(useFractal: Boolean = false) : setFloatUniform("in_aspectRatio", width / max(height, 0.001f)) } /** * Sets whether to inverse the luminosity of the noise. * * By default noise will be used as a luma matte as is. This means that you will see color in * the brighter area. If you want to invert it, meaning blend color onto the darker side, set to * true. */ fun setInverseNoiseLuminosity(inverse: Boolean) { setFloatUniform("in_inverseLuma", if (inverse) 1f else 0f) } /** Current noise movements in x, y, and z axes. */ var noiseOffsetX: Float = 0f private set Loading