Skip to content

Commit 0e9cccd

Browse files
committed
fix: resolve black rendering issues by enabling blending and using ES shaders
1 parent 5959500 commit 0e9cccd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

example/src/main/java/dev/eatgrapes/live2d/example/Main.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ private void init() {
3838
GL.createCapabilities();
3939
glfwSwapInterval(1);
4040

41+
// Required for Live2D transparency and masking
42+
glEnable(GL_BLEND);
43+
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
44+
4145
glfwSetCursorPosCallback(window, (win, x, y) -> {
4246
float nx = (float) (x / 400.0 - 1.0);
4347
float ny = (float) (1.0 - y / 400.0);
@@ -108,6 +112,10 @@ private int loadTex(String p) throws Exception {
108112
}
109113
tex = glGenTextures();
110114
glBindTexture(GL_TEXTURE_2D, tex);
115+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
116+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
117+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
118+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
111119
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, img);
112120
STBImage.stbi_image_free(img);
113121
Files.delete(tmp);

scripts/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ def build():
7171
classes = os.path.join(out, "classes")
7272
os.makedirs(classes)
7373

74+
# Shaders
7475
sd = os.path.join(classes, "live2d", "shaders")
7576
os.makedirs(sd)
76-
ss = os.path.join(SDK_DIR, "Framework/src/Rendering/OpenGL/Shaders/Standard")
77+
ss = os.path.join(SDK_DIR, "Framework/src/Rendering/OpenGL/Shaders/StandardES")
7778
for f in os.listdir(ss): shutil.copy(os.path.join(ss, f), sd)
7879

7980
src = os.path.join(root, "binding/src/main/java")

0 commit comments

Comments
 (0)