From 9d149ef58ab0fa36fdbb90a9dc40b48328661eb6 Mon Sep 17 00:00:00 2001 From: litwak913 Date: Tue, 17 Sep 2024 01:11:52 +0800 Subject: [PATCH 1/4] fix: glsl on opengl 2.1 --- assets/shaders/OutlineFragment.glsl | 5 +++-- assets/shaders/TCPBFragment.glsl | 2 +- assets/shaders/TCPBVertex.glsl | 2 +- core/src/cn/harryh/arkpets/ArkChar.java | 1 + core/src/cn/harryh/arkpets/ArkPets.java | 3 +++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/assets/shaders/OutlineFragment.glsl b/assets/shaders/OutlineFragment.glsl index 92ce8c0a..cd226ec5 100644 --- a/assets/shaders/OutlineFragment.glsl +++ b/assets/shaders/OutlineFragment.glsl @@ -4,12 +4,13 @@ // Gap Seaming and Ouline Effect Fragment Shader for TwoColorPolygonBatch. -#version 130 +#version 120 varying vec2 v_texCoords; // From VS uniform sampler2D u_texture; // From TCPB uniform vec3 u_outlineColor; // Required uniform float u_outlineWidth; // Required +uniform ivec2 u_textureSize; const float c_alphaLv0 = 0.1; const float c_alphaLv1 = 0.5; @@ -31,7 +32,7 @@ vec4[8] getNeighbors(sampler2D tex, vec2 texCoords, vec2 offset) { void main() { vec4 texColor = texture2D(u_texture, v_texCoords); - ivec2 texSize = textureSize(u_texture, 0); + ivec2 texSize = u_textureSize; if (texColor.a < c_alphaLv0) { // Outline effect apply on transparent areas diff --git a/assets/shaders/TCPBFragment.glsl b/assets/shaders/TCPBFragment.glsl index e1d08d4a..18c72701 100644 --- a/assets/shaders/TCPBFragment.glsl +++ b/assets/shaders/TCPBFragment.glsl @@ -4,7 +4,7 @@ // Common Fragment Shader for TwoColorPolygonBatch. -#version 130 +#version 120 #ifdef GL_ES #define LOWP lowp diff --git a/assets/shaders/TCPBVertex.glsl b/assets/shaders/TCPBVertex.glsl index 8c38c3b7..cc8b7027 100644 --- a/assets/shaders/TCPBVertex.glsl +++ b/assets/shaders/TCPBVertex.glsl @@ -4,7 +4,7 @@ // Common Vertex Shader for TwoColorPolygonBatch. -#version 130 +#version 120 attribute vec4 a_position; attribute vec4 a_light; diff --git a/core/src/cn/harryh/arkpets/ArkChar.java b/core/src/cn/harryh/arkpets/ArkChar.java index f75cb088..20718d40 100644 --- a/core/src/cn/harryh/arkpets/ArkChar.java +++ b/core/src/cn/harryh/arkpets/ArkChar.java @@ -227,6 +227,7 @@ protected void renderToBatch() { shader2.bind(); shader2.setUniformf("u_outlineColor", 1f, 1f, 0f); shader2.setUniformf("u_outlineWidth", outlineWidth.now()); + shader2.setUniformi("u_textureSize", passedTexture.getWidth(), passedTexture.getHeight()); batch.setShader(shader2); ScreenUtils.clear(0, 0, 0, 0, true); batch.begin(); diff --git a/core/src/cn/harryh/arkpets/ArkPets.java b/core/src/cn/harryh/arkpets/ArkPets.java index 317d7d86..86419bd0 100644 --- a/core/src/cn/harryh/arkpets/ArkPets.java +++ b/core/src/cn/harryh/arkpets/ArkPets.java @@ -18,6 +18,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.InputProcessor; +import com.badlogic.gdx.graphics.GL20; import java.util.HashMap; import java.util.List; @@ -61,6 +62,8 @@ public void create() { config = Objects.requireNonNull(ArkConfig.getConfig(), "ArkConfig returns a null instance, please check the config file."); Gdx.input.setInputProcessor(this); Gdx.graphics.setForegroundFPS(config.display_fps); + Logger.info("System", "OpenGL Version " + Gdx.gl.glGetString(GL20.GL_VERSION)); + Logger.info("System", "OpenGL Vendor " + Gdx.gl.glGetString(GL20.GL_VENDOR)); // 2.Character setup Logger.info("App", "Using model asset \"" + config.character_asset + "\""); From 44401ff96fe34f3bf729afc441e7a526383e183c Mon Sep 17 00:00:00 2001 From: litwak913 Date: Sun, 22 Sep 2024 09:04:45 +0800 Subject: [PATCH 2/4] feat: background color --- assets/ArkPetsConfigDefault.json | 1 + assets/UI/SettingsModule.fxml | 4 ++++ core/src/cn/harryh/arkpets/ArkChar.java | 3 ++- core/src/cn/harryh/arkpets/ArkConfig.java | 17 +++++++++++++++++ .../src/cn/harryh/arkpets/EmbeddedLauncher.java | 6 +++--- .../arkpets/controllers/SettingsModule.java | 12 ++++++++++++ 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/assets/ArkPetsConfigDefault.json b/assets/ArkPetsConfigDefault.json index a6282179..4213a6e1 100644 --- a/assets/ArkPetsConfigDefault.json +++ b/assets/ArkPetsConfigDefault.json @@ -1,4 +1,5 @@ { + "background_color":"#00000000", "behavior_ai_activation":8, "behavior_allow_interact":true, "behavior_allow_sit":true, diff --git a/assets/UI/SettingsModule.fxml b/assets/UI/SettingsModule.fxml index 7b773389..9be5e0a1 100644 --- a/assets/UI/SettingsModule.fxml +++ b/assets/UI/SettingsModule.fxml @@ -35,6 +35,10 @@