Skip to content

Instantly share code, notes, and snippets.

@Ttiki
Created February 25, 2022 18:30
Show Gist options
  • Save Ttiki/b8dc980f80f9072baaf335c65ce020f9 to your computer and use it in GitHub Desktop.
Save Ttiki/b8dc980f80f9072baaf335c65ce020f9 to your computer and use it in GitHub Desktop.
A shader wich fades between two images depending on your battery level. This shader is to be used inside the Android app "Shader Editor". Read the top comments for explanation on how to set-up it inside the app.
//Author: (Lord) Clément 'Ttiki' Combier
//License: MIT License Copyright (c) 2022 Clément Combier
//This shader was created on/for the Android app : Shader Editor
//To use this shader, load two images (three dots menu > Add uniform/texture > Sample2D tab > + button, add your image)
//Now, you need to give your images a name. For your first image (the one which will be displayed when your battery is at 100%), put "img1".
//For your second image, put img2.
//Set this shader as your wallpaper (available in the app inside the three dots menu)
//Shader Editor can be found on the Google Play Store here: https://play.google.com/store/apps/details?id=de.markusfisch.android.shadereditor
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
uniform vec2 resolution;
uniform float battery;
uniform sampler2D img1;
uniform sampler2D img2;
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
vec4 beb = texture2D(img1, uv);
vec4 balkany = texture2D(img2, uv);
img1.xyz *= vec3(battery);
img2.xyz *= vec3(1.0-battery);
gl_FragColor = img1 + img2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment