summaryrefslogtreecommitdiff
path: root/shaders/skia/1939.shader_test
blob: 003e96f5eb169393a94e33808e9aac11860df969 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
[require]
GLSL >= 1.40
GL_KHR_blend_equation_advanced

[fragment shader]
#version 140

#extension GL_KHR_blend_equation_advanced : require
out vec4 sk_FragColor;
layout (blend_support_all_equations) out ;
uniform vec4 ucolor_Stage1;
uniform vec2 ubaseFrequency_Stage2;
uniform float uz_Stage2;
uniform vec2 ubaseFrequency_Stage4;
uniform float uz_Stage4;
uniform sampler2D uTextureSampler_0_Stage0;
uniform sampler2D uTextureSampler_0_Stage2;
uniform sampler2D uTextureSampler_1_Stage2;
uniform sampler2D uTextureSampler_0_Stage4;
uniform sampler2D uTextureSampler_1_Stage4;
uniform sampler2D uTextureSampler_0_Stage5;
in vec2 vTextureCoords_Stage0;
flat in int vTexIndex_Stage0;
in vec2 vIntTextureCoords_Stage0;
in vec4 vinColor_Stage0;
in vec2 vTransformedCoords_0_Stage0;
in vec2 vTransformedCoords_1_Stage0;
vec3 fade_Stage2(vec3 t) {
    return ((t * t) * t) * (t * (t * 6.0 - 15.0) + 10.0);
}
float perm_Stage2(float x) {
    return texture(uTextureSampler_0_Stage2, vec2(fract(x / 256.0), 0.0)).x * 255.0;
}
float grad_Stage2(float x, vec3 p) {
    return dot(texture(uTextureSampler_1_Stage2, vec2(fract(x / 16.0), 0.0)).xyz * 255.0 - vec3(1.0), p);
}
float lerp_Stage2(float a, float b, float w) {
    return a + w * (b - a);
}
float noise_Stage2(vec3 p) {
    vec3 P = mod(floor(p), 256.0);
    p -= floor(p);
    vec3 f = fade_Stage2(p);
    float A = perm_Stage2(P.x) + P.y;
    float AA = perm_Stage2(A) + P.z;
    float AB = perm_Stage2(A + 1.0) + P.z;
    float B = perm_Stage2(P.x + 1.0) + P.y;
    float BA = perm_Stage2(B) + P.z;
    float BB = perm_Stage2(B + 1.0) + P.z;
    float result = lerp_Stage2(lerp_Stage2(lerp_Stage2(grad_Stage2(perm_Stage2(AA), p), grad_Stage2(perm_Stage2(BA), p + vec3(-1.0, 0.0, 0.0)), f.x), lerp_Stage2(grad_Stage2(perm_Stage2(AB), p + vec3(0.0, -1.0, 0.0)), grad_Stage2(perm_Stage2(BB), p + vec3(-1.0, -1.0, 0.0)), f.x), f.y), lerp_Stage2(lerp_Stage2(grad_Stage2(perm_Stage2(AA + 1.0), p + vec3(0.0, 0.0, -1.0)), grad_Stage2(perm_Stage2(BA + 1.0), p + vec3(-1.0, 0.0, -1.0)), f.x), lerp_Stage2(grad_Stage2(perm_Stage2(AB + 1.0), p + vec3(0.0, -1.0, -1.0)), grad_Stage2(perm_Stage2(BB + 1.0), p + vec3(-1.0, -1.0, -1.0)), f.x), f.y), f.z);
    return result;
}
float noiseOctaves_Stage2(vec3 p) {
    float result = 0.0;
    float ratio = 1.0;
    for (float i = 0.0;i < 7.0; i++) {
        result += noise_Stage2(p) / ratio;
        p *= 2.0;
        ratio *= 2.0;
    }
    return (result + 1.0) / 2.0;
}
vec3 fade_Stage4(vec3 t) {
    return ((t * t) * t) * (t * (t * 6.0 - 15.0) + 10.0);
}
float perm_Stage4(float x) {
    return texture(uTextureSampler_0_Stage4, vec2(fract(x / 256.0), 0.0)).x * 255.0;
}
float grad_Stage4(float x, vec3 p) {
    return dot(texture(uTextureSampler_1_Stage4, vec2(fract(x / 16.0), 0.0)).xyz * 255.0 - vec3(1.0), p);
}
float lerp_Stage4(float a, float b, float w) {
    return a + w * (b - a);
}
float noise_Stage4(vec3 p) {
    vec3 P = mod(floor(p), 256.0);
    p -= floor(p);
    vec3 f = fade_Stage4(p);
    float A = perm_Stage4(P.x) + P.y;
    float AA = perm_Stage4(A) + P.z;
    float AB = perm_Stage4(A + 1.0) + P.z;
    float B = perm_Stage4(P.x + 1.0) + P.y;
    float BA = perm_Stage4(B) + P.z;
    float BB = perm_Stage4(B + 1.0) + P.z;
    float result = lerp_Stage4(lerp_Stage4(lerp_Stage4(grad_Stage4(perm_Stage4(AA), p), grad_Stage4(perm_Stage4(BA), p + vec3(-1.0, 0.0, 0.0)), f.x), lerp_Stage4(grad_Stage4(perm_Stage4(AB), p + vec3(0.0, -1.0, 0.0)), grad_Stage4(perm_Stage4(BB), p + vec3(-1.0, -1.0, 0.0)), f.x), f.y), lerp_Stage4(lerp_Stage4(grad_Stage4(perm_Stage4(AA + 1.0), p + vec3(0.0, 0.0, -1.0)), grad_Stage4(perm_Stage4(BA + 1.0), p + vec3(-1.0, 0.0, -1.0)), f.x), lerp_Stage4(grad_Stage4(perm_Stage4(AB + 1.0), p + vec3(0.0, -1.0, -1.0)), grad_Stage4(perm_Stage4(BB + 1.0), p + vec3(-1.0, -1.0, -1.0)), f.x), f.y), f.z);
    return result;
}
float noiseOctaves_Stage4(vec3 p) {
    float result = 0.0;
    float ratio = 1.0;
    for (float i = 0.0;i < 8.0; i++) {
        result += noise_Stage4(p) / ratio;
        p *= 2.0;
        ratio *= 2.0;
    }
    return (result + 1.0) / 2.0;
}
void main() {
    vec4 outputColor_Stage0;
    {
        outputColor_Stage0 = vinColor_Stage0;
        vec2 uv = vTextureCoords_Stage0;
        vec4 texColor;
        {
            texColor = texture(uTextureSampler_0_Stage0, uv);
        }
        float distance = 7.96875 * (texColor.x - 0.50196081399917603);
        vec2 dist_grad = vec2(dFdx(distance), -dFdy(distance));
        float dg_len2 = dot(dist_grad, dist_grad);
        if (dg_len2 < 9.9999997473787516e-05) {
            dist_grad = vec2(0.70709997415542603, 0.70709997415542603);
        } else {
            dist_grad = dist_grad * inversesqrt(dg_len2);
        }
    }
    vec4 output_Stage2;
    {
        vec2 coords = vTransformedCoords_0_Stage0 * ubaseFrequency_Stage2;
        float r = noiseOctaves_Stage2(vec3(coords, uz_Stage2));
        float g = noiseOctaves_Stage2(vec3(coords, uz_Stage2));
        float b = noiseOctaves_Stage2(vec3(coords, uz_Stage2));
        float a = noiseOctaves_Stage2(vec3(coords, uz_Stage2));
        output_Stage2 = vec4(r, g, b, a);
        output_Stage2 = clamp(output_Stage2, 0.0, 1.0);
        output_Stage2 = vec4(output_Stage2.xyz * output_Stage2.www, output_Stage2.w);
    }
    vec4 output_Stage3;
    {
        output_Stage3 = floor(output_Stage2 * 255.0 + 0.5) / 255.0;
        {
            output_Stage3.xyz = floor((output_Stage3.xyz * output_Stage3.w) * 255.0 + 0.5) / 255.0;
        }
    }
    vec4 output_Stage4;
    {
        vec2 coords = vTransformedCoords_1_Stage0 * ubaseFrequency_Stage4;
        float r = noiseOctaves_Stage4(vec3(coords, uz_Stage4));
        float g = noiseOctaves_Stage4(vec3(coords, uz_Stage4));
        float b = noiseOctaves_Stage4(vec3(coords, uz_Stage4));
        float a = noiseOctaves_Stage4(vec3(coords, uz_Stage4));
        output_Stage4 = vec4(r, g, b, a);
        output_Stage4 = clamp(output_Stage4, 0.0, 1.0);
        output_Stage4 = vec4(output_Stage4.xyz * output_Stage4.www, output_Stage4.w);
    }
    vec4 output_Stage5;
    {
        float nonZeroAlpha = max(output_Stage4.w, 9.9999997473787516e-05);
        vec4 coord = vec4(output_Stage4.xyz / nonZeroAlpha, nonZeroAlpha);
        coord = coord * 0.9960939884185791 + vec4(0.0019529999699443579, 0.0019529999699443579, 0.0019529999699443579, 0.0019529999699443579);
        output_Stage5.w = texture(uTextureSampler_0_Stage5, vec2(coord.w, 0.125)).w;
        output_Stage5.x = texture(uTextureSampler_0_Stage5, vec2(coord.x, 0.375)).w;
        output_Stage5.y = texture(uTextureSampler_0_Stage5, vec2(coord.y, 0.625)).w;
        output_Stage5.z = texture(uTextureSampler_0_Stage5, vec2(coord.z, 0.875)).w;
        output_Stage5.xyz *= output_Stage5.w;
    }
    {
        sk_FragColor = output_Stage5 * outputColor_Stage0;
    }
}

[vertex shader]
#version 140

uniform vec4 sk_RTAdjust;
uniform vec2 uAtlasDimensionsInv_Stage0;
uniform mat3 uViewM_Stage0;
uniform mat3 uCoordTransformMatrix_0_Stage0;
uniform mat3 uCoordTransformMatrix_1_Stage0;
in vec2 inPosition;
in vec4 inColor;
in uvec2 inTextureCoords;
out vec2 vTextureCoords_Stage0;
flat out int vTexIndex_Stage0;
out vec2 vIntTextureCoords_Stage0;
out vec4 vinColor_Stage0;
out vec2 vTransformedCoords_0_Stage0;
out vec2 vTransformedCoords_1_Stage0;
void main() {
    ivec2 signedCoords = ivec2(int(inTextureCoords.x), int(inTextureCoords.y));
    vec2 unormTexCoords = vec2(float(signedCoords.x / 2), float(signedCoords.y / 2));
    vTextureCoords_Stage0 = unormTexCoords * uAtlasDimensionsInv_Stage0;
    vTexIndex_Stage0 = 0;
    vIntTextureCoords_Stage0 = unormTexCoords;
    vinColor_Stage0 = inColor;
    vec3 pos3 = uViewM_Stage0 * vec3(inPosition, 1.0);
    vTransformedCoords_0_Stage0 = (uCoordTransformMatrix_0_Stage0 * vec3(inPosition, 1.0)).xy;
    vTransformedCoords_1_Stage0 = (uCoordTransformMatrix_1_Stage0 * vec3(inPosition, 1.0)).xy;
    gl_Position = vec4(pos3.x, pos3.y, 0.0, pos3.z);
    gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w);
}