mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 06:48:26 +00:00
added Type Jam puzzle app for review (#1554)
* added Type Jam puzzle app for review * pr round 2 prep * updated ci scripts for varfont_shader_puzzle * resolved unused and minor variable naming issues * rotator tiles row and col are final vars now * removed unused import and print from production * made constructors const where needed * pages_flow export refactored to directly come from that file * removed old api commented out section from FragmentShaded * updated pubspec yaml to correct project name * dart min version updated; removed unnecessary commented out dependencies from pubspec.yaml * updated pubspec.yaml min flutter version to ensure FragmentShader support * added/edited comments for explanation, esp on var fonts; removed obsolete comments * trailing newline added to pubspec.yaml eof
This commit is contained in:
35
experimental/varfont_shader_puzzle/shaders/row_offset.frag
Normal file
35
experimental/varfont_shader_puzzle/shaders/row_offset.frag
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2023 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
#define PI 3.1415926538
|
||||
|
||||
layout(location = 0) uniform float uTime;
|
||||
layout(location = 1) uniform vec2 uSize;
|
||||
layout(location = 3) uniform float uDampener;
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(location = 2) uniform sampler2D uTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
float piTime = uTime * PI * 2;
|
||||
|
||||
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
|
||||
|
||||
float levels = 5;
|
||||
float maxMag = 0.1;
|
||||
float minMag = 0.02;
|
||||
float magMod = maxMag / levels;
|
||||
float row = floor(texCoord.y * uSize.y * 0.25); // resolution/density of rows
|
||||
float offsetDir = mod(row, 2) == 0 ? -1 : 1;
|
||||
float sinFn = cos(texCoord.y * 1 * PI + piTime);
|
||||
float offset = (offsetDir * (minMag + maxMag * sinFn)) * uDampener;
|
||||
|
||||
vec2 offsetTexCoord = vec2(texCoord.x + offset, texCoord.y);
|
||||
vec4 outColor = texture(uTexture, offsetTexCoord);
|
||||
if (texCoord.x + offset < 0.0 || texCoord.x + offset > 1.0) {
|
||||
outColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
fragColor = outColor;
|
||||
}
|
||||
Reference in New Issue
Block a user