📝 Update tutorial
This commit is contained in:
@@ -86,27 +86,28 @@ Please study this code carefully, all of it is explained with inline comments.
|
|||||||
|
|
||||||
```glsl
|
```glsl
|
||||||
// The content from common.glsl is automatically prepended to each shader effect. This
|
// The content from common.glsl is automatically prepended to each shader effect. This
|
||||||
// provides the standard input "vec2 iTexCoord", the standard output "vec4 oColor" as well
|
// provides the standard input:
|
||||||
// as some standard uniforms which will be updated during the animation:
|
|
||||||
|
|
||||||
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
|
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
|
||||||
// sampler2D uTexture: Contains the texture of the window.
|
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
|
||||||
// float uProgress: A value which transitions from 0 to 1 during the entire animation.
|
// float uProgress: A value which transitions from 0 to 1 during the animation.
|
||||||
// float uTime: A steadily increasing value in seconds.
|
// float uTime: A steadily increasing value in seconds.
|
||||||
// vec2 uSize: The size of uTexture in pixels.
|
// vec2 uSize: The size of uTexture in pixels.
|
||||||
// float uPadding: The empty area around the actual window (e.g. where the shadow is drawn).
|
// float uPadding: The empty area around the actual window (e.g. where the shadow
|
||||||
|
// is drawn). For now, this will only be set on GNOME.
|
||||||
|
|
||||||
|
// Furthermore, there are two global methods for reading the window input color and
|
||||||
|
// setting the shader output color. Both methods assume straight alpha:
|
||||||
|
|
||||||
|
// vec4 getInputColor(vec2 coords)
|
||||||
|
// void setOutputColor(vec4 outColor)
|
||||||
|
|
||||||
// The width of the fading effect is loaded from the settings.
|
// The width of the fading effect is loaded from the settings.
|
||||||
uniform float uFadeWidth;
|
uniform float uFadeWidth;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Get the color from the window texture.
|
// Get the color from the window texture.
|
||||||
oColor = texture2D(uTexture, iTexCoord.st);
|
vec4 oColor = getInputColor(iTexCoord.st);
|
||||||
|
|
||||||
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
|
|
||||||
if (oColor.a > 0) {
|
|
||||||
oColor.rgb /= oColor.a;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Radial distance from window edge to the window's center.
|
// Radial distance from window edge to the window's center.
|
||||||
float dist = length(iTexCoord.st - 0.5) * 2.0 / sqrt(2.0);
|
float dist = length(iTexCoord.st - 0.5) * 2.0 / sqrt(2.0);
|
||||||
@@ -121,6 +122,8 @@ void main() {
|
|||||||
|
|
||||||
// Apply the mask to the output.
|
// Apply the mask to the output.
|
||||||
oColor.a *= mask;
|
oColor.a *= mask;
|
||||||
|
|
||||||
|
setOutputColor(oColor);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user