Skip to content

Commit 7ad39ea

Browse files
rollback alpha implement
1 parent 5d95783 commit 7ad39ea

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

res/raw/view_renderer.frag

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ uniform sampler2D texture;
1010
varying vec2 uv;
1111

1212
void main() {
13-
vec4 color = texture2D(texture, uv);
14-
color.a *= ALPHA;
15-
if(color.a <= 0.0) discard;
13+
vec4 diffuse = vec4(1.0);
1614

1715
if(MODE == 0) {
18-
color.rgb *= color.a;
19-
} else if(ALPHA == 1.0){
20-
if(color.a >= 1.0)discard;
21-
} else {
22-
discard;
16+
diffuse = texture2D(texture, uv);
2317
}
2418

25-
gl_FragColor = color;
19+
if(diffuse.a <= 0.0)
20+
discard;
21+
22+
gl_FragColor = diffuse;
2623
}

src/br/nullexcept/mux/core/texel/GLTexel.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static void drawViewLayers(float[][] vertices, int[] textures, float[] al
6666
GL_ONE,
6767
GL_ONE_MINUS_SRC_ALPHA,
6868
GL_ONE,
69-
GL_ONE
69+
GL_ONE_MINUS_SRC_ALPHA
7070
);
7171

7272

@@ -85,17 +85,11 @@ public static void drawViewLayers(float[][] vertices, int[] textures, float[] al
8585
glVertexAttribPointer(program.uv, 2, GL_FLOAT, false, 0, bufferUV);
8686
glUniform1i(program.texture, GL_TEXTURE_2D);
8787

88-
/**
89-
* @TODO: Need better implement for fix dark border + alpha, with low gpu cost
90-
* MODE 0 = FILL
91-
* MODE 1 = "ANTILIAZING""
92-
*/
93-
for (int x = 0; x < 2; x++) {
94-
glUniform1iv(program.params, new int[]{
95-
x, Math.round(alphas[i] * 255)
96-
});
97-
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
98-
}
88+
glUniform1iv(program.params, new int[]{
89+
0,
90+
Math.round(alphas[i] * 255)
91+
});
92+
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
9993
}
10094

10195
program.unbind();

src/br/nullexcept/mux/core/texel/ViewRenderer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void drawInternal(CanvasTexel canvas, View view){
2828
}
2929
canvas.begin();
3030
canvas.reset();
31+
canvas.alpha(view.getAlpha());
3132
view.onDraw(canvas);
3233
if (view instanceof ViewGroup){
3334
canvas.end();

0 commit comments

Comments
 (0)