Loading weathereffects/Android.bp +20 −1 Original line number Diff line number Diff line Loading @@ -72,5 +72,24 @@ android_app { }, } // TODO(b/300991599): setup test configuration. android_test { name: "weathereffects_tests", instrumentation_for: "WeatherEffects", manifest: "AndroidManifest.xml", test_suites: ["general-tests"], sdk_version: "current", srcs: [ "tests/src/**/*.java", "tests/src/**/*.kt", ], static_libs: [ "WeatherEffectsLib", "androidx.test.rules", "androidx.test.ext.junit", "androidx.test.core", "androidx.test.runner", "kotlinx_coroutines_test", "truth" ], } weathereffects/TEST_MAPPING 0 → 100644 +7 −0 Original line number Diff line number Diff line { "presubmit": [ { "name": "weathereffects_tests" } ] } No newline at end of file weathereffects/assets/shaders/color_grading_lut.agsl +6 −4 Original line number Diff line number Diff line Loading @@ -57,13 +57,15 @@ vec4 main(float2 fragCoord) { vec3 colorFloor = floor(colorTmp) * SLICE_LAST_IDX_INV; ivec2 uvFloor = ivec2( int(colorFloor.b * LAST_SLICE_FIRST_IDX + colorFloor.r * SLICE_LAST_IDX), int(colorFloor.g * SLICE_LAST_IDX)); int(colorFloor.g * SLICE_LAST_IDX) ); // Calculate the ceil UVs. vec3 colorCeil = ceil(colorTmp) * SLICE_LAST_IDX_INV; ivec2 uvCeil = ivec2( int(colorCeil.b * LAST_SLICE_FIRST_IDX + colorCeil.r * SLICE_LAST_IDX), int(colorCeil.g * SLICE_LAST_IDX)); int(colorCeil.g * SLICE_LAST_IDX) ); /* * Fetch the color from the LUT, and combine both floor and ceiling options based on the Loading weathereffects/assets/shaders/fog_effect.agsl +8 −6 Original line number Diff line number Diff line Loading @@ -20,10 +20,11 @@ uniform float2 uvOffsetFgd; uniform float2 uvScaleFgd; uniform float2 uvOffsetBgd; uniform float2 uvScaleBgd; uniform float2 timeForeground; uniform float2 timeBackground; uniform float screenAspectRatio; uniform float2 screenSize; uniform half2 timeForeground; uniform half2 timeBackground; uniform half screenAspectRatio; uniform half2 screenSize; uniform half pixelDensity; #include "shaders/constants.agsl" #include "shaders/utils.agsl" Loading Loading @@ -56,12 +57,13 @@ vec4 main(float2 fragCoord) { float frontFog = smoothstep(-0.616, 0.552, fbm(vec3(uv * 0.886, 123.1), timeForeground)); float bgdFog = smoothstep(-0.744, 0.28, fbm(vec3(uv * 1.2, 231.), timeBackground)); float dithering = (1. - idGenerator(uv) * 0.161); float dither = 1. - triangleNoise(fragCoord * pixelDensity) * 0.161; color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.8 * dithering * bgdFog); color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.8 * dither * bgdFog); // 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); return color; } weathereffects/assets/shaders/utils.agsl +9 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,15 @@ float wiggle(float time, float wiggleSpeed) { * sin(wiggleSpeed * time) - 0.5; } // Noise range of [-1.0, 1.0[ with triangle distribution. float triangleNoise(vec2 n) { n = fract(n * vec2(5.3987, 5.4421)); n += dot(n.yx, n.xy + vec2(21.5351, 14.3137)); float xy = n.x * n.y; // compute in [0..2[ and remap to [-1.0..1.0[ return fract(xy * 95.4307) + fract(xy * 75.04961) - 1.0; } /* * This is the normal blend mode in which the foreground is painted on top of the background based * on the foreground opacity. Loading Loading
weathereffects/Android.bp +20 −1 Original line number Diff line number Diff line Loading @@ -72,5 +72,24 @@ android_app { }, } // TODO(b/300991599): setup test configuration. android_test { name: "weathereffects_tests", instrumentation_for: "WeatherEffects", manifest: "AndroidManifest.xml", test_suites: ["general-tests"], sdk_version: "current", srcs: [ "tests/src/**/*.java", "tests/src/**/*.kt", ], static_libs: [ "WeatherEffectsLib", "androidx.test.rules", "androidx.test.ext.junit", "androidx.test.core", "androidx.test.runner", "kotlinx_coroutines_test", "truth" ], }
weathereffects/TEST_MAPPING 0 → 100644 +7 −0 Original line number Diff line number Diff line { "presubmit": [ { "name": "weathereffects_tests" } ] } No newline at end of file
weathereffects/assets/shaders/color_grading_lut.agsl +6 −4 Original line number Diff line number Diff line Loading @@ -57,13 +57,15 @@ vec4 main(float2 fragCoord) { vec3 colorFloor = floor(colorTmp) * SLICE_LAST_IDX_INV; ivec2 uvFloor = ivec2( int(colorFloor.b * LAST_SLICE_FIRST_IDX + colorFloor.r * SLICE_LAST_IDX), int(colorFloor.g * SLICE_LAST_IDX)); int(colorFloor.g * SLICE_LAST_IDX) ); // Calculate the ceil UVs. vec3 colorCeil = ceil(colorTmp) * SLICE_LAST_IDX_INV; ivec2 uvCeil = ivec2( int(colorCeil.b * LAST_SLICE_FIRST_IDX + colorCeil.r * SLICE_LAST_IDX), int(colorCeil.g * SLICE_LAST_IDX)); int(colorCeil.g * SLICE_LAST_IDX) ); /* * Fetch the color from the LUT, and combine both floor and ceiling options based on the Loading
weathereffects/assets/shaders/fog_effect.agsl +8 −6 Original line number Diff line number Diff line Loading @@ -20,10 +20,11 @@ uniform float2 uvOffsetFgd; uniform float2 uvScaleFgd; uniform float2 uvOffsetBgd; uniform float2 uvScaleBgd; uniform float2 timeForeground; uniform float2 timeBackground; uniform float screenAspectRatio; uniform float2 screenSize; uniform half2 timeForeground; uniform half2 timeBackground; uniform half screenAspectRatio; uniform half2 screenSize; uniform half pixelDensity; #include "shaders/constants.agsl" #include "shaders/utils.agsl" Loading Loading @@ -56,12 +57,13 @@ vec4 main(float2 fragCoord) { float frontFog = smoothstep(-0.616, 0.552, fbm(vec3(uv * 0.886, 123.1), timeForeground)); float bgdFog = smoothstep(-0.744, 0.28, fbm(vec3(uv * 1.2, 231.), timeBackground)); float dithering = (1. - idGenerator(uv) * 0.161); float dither = 1. - triangleNoise(fragCoord * pixelDensity) * 0.161; color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.8 * dithering * bgdFog); color.rgb = normalBlendWithWhiteSrc(color.rgb, 0.8 * dither * bgdFog); // 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); return color; }
weathereffects/assets/shaders/utils.agsl +9 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,15 @@ float wiggle(float time, float wiggleSpeed) { * sin(wiggleSpeed * time) - 0.5; } // Noise range of [-1.0, 1.0[ with triangle distribution. float triangleNoise(vec2 n) { n = fract(n * vec2(5.3987, 5.4421)); n += dot(n.yx, n.xy + vec2(21.5351, 14.3137)); float xy = n.x * n.y; // compute in [0..2[ and remap to [-1.0..1.0[ return fract(xy * 95.4307) + fract(xy * 75.04961) - 1.0; } /* * This is the normal blend mode in which the foreground is painted on top of the background based * on the foreground opacity. Loading