Skip to content

Commit

Permalink
refactor: glsl alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
litwak913 committed Sep 30, 2024
1 parent 44401ff commit 444e720
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions assets/shaders/OutlineFragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ uniform sampler2D u_texture; // From TCPB
uniform vec3 u_outlineColor; // Required
uniform float u_outlineWidth; // Required
uniform ivec2 u_textureSize;
uniform float u_alpha;

const float c_alphaLv0 = 0.1;
const float c_alphaLv1 = 0.5;
Expand Down Expand Up @@ -77,4 +78,6 @@ void main() {
// No effect apply on other areas
gl_FragColor = texColor;
}
// Alpha
gl_FragColor.a -= (1 - u_alpha);
}
3 changes: 3 additions & 0 deletions core/src/cn/harryh/arkpets/ArkChar.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class ArkChar {
protected final AnimClipGroup animList;
protected final HashMap<AnimStage, Insert> stageInsertMap;

protected float alpha;

/** Initializes an ArkPets character.
* @param config The ArkPets Config instance which contains the asset's information and other essential settings.
* @param scale The scale of the skeleton.
Expand Down Expand Up @@ -229,6 +231,7 @@ protected void renderToBatch() {
shader2.setUniformf("u_outlineColor", 1f, 1f, 0f);
shader2.setUniformf("u_outlineWidth", outlineWidth.now());
shader2.setUniformi("u_textureSize", passedTexture.getWidth(), passedTexture.getHeight());
shader2.setUniformf("u_alpha", alpha);
batch.setShader(shader2);
ScreenUtils.clear(0, 0, 0, 0, true);
batch.begin();
Expand Down
2 changes: 1 addition & 1 deletion core/src/cn/harryh/arkpets/ArkConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ArkConfig implements Serializable {


// Config items and default values:
/** @since ArkPets 3.4 */ @JSONField(defaultValue = "#00000000")
/** @since ArkPets 3.3 */ @JSONField(defaultValue = "#00000000")
public String background_color;
/** @since ArkPets 1.0 */ @JSONField(defaultValue = "8")
public int behavior_ai_activation;
Expand Down
2 changes: 1 addition & 1 deletion core/src/cn/harryh/arkpets/ArkPets.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void render() {
setWindowPos();
if (!windowAlpha.isEnded()) {
windowAlpha.addProgress(Gdx.graphics.getDeltaTime());
hWndMine.setWindowAlpha(windowAlpha.now());
cha.alpha = windowAlpha.now();
}
promiseToolwindowStyle(1);

Expand Down
2 changes: 1 addition & 1 deletion core/src/cn/harryh/arkpets/tray/MemberTrayImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void onExit() {
public void run() {
Gdx.app.exit();
}
}, (int)durationNormal.toSeconds());
}, (int)durationNormal.toMillis());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class EmbeddedLauncher {
// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument

public static void main (String[] args) {
ArkConfig appConfig = Objects.requireNonNull(ArkConfig.getConfig());
ArgPending.argCache = args;
// Logger
Logger.initialize(LogConfig.logCorePath, LogConfig.logCoreMaxKeep);
ArkConfig appConfig = Objects.requireNonNull(ArkConfig.getConfig());
try {
Logger.setLevel(appConfig.logging_level);
} catch (Exception ignored) {
Expand Down

0 comments on commit 444e720

Please sign in to comment.