Skip to content

Commit

Permalink
fix(shader): problems from #78
Browse files Browse the repository at this point in the history
* Fix outline lose when render bg color
* Fix incorrect alpha calculation
  • Loading branch information
isHarryh committed Oct 7, 2024
1 parent 9b09f08 commit 51d9859
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions assets/shaders/OutlineFragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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;
uniform float u_alpha;
uniform ivec2 u_textureSize; // Required
uniform float u_alpha; // Required

const float c_alphaLv0 = 0.1;
const float c_alphaLv1 = 0.5;
Expand Down Expand Up @@ -78,6 +78,7 @@ void main() {
// No effect apply on other areas
gl_FragColor = texColor;
}
// Alpha
gl_FragColor.a -= (1 - u_alpha);

// Ultimate alpha control
gl_FragColor.a *= u_alpha;
}
2 changes: 1 addition & 1 deletion core/src/cn/harryh/arkpets/ArkChar.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ protected void renderToBatch() {
batch.setShader(shader1);
ScreenUtils.clear(0, 0, 0, 0, true);
batch.begin();
batch.draw(bgTexture, 0, 0);
renderer.draw(batch, skeleton);
batch.end();
batch.setShader(null);
Expand All @@ -242,6 +241,7 @@ protected void renderToBatch() {
batch.setShader(shader2);
ScreenUtils.clear(0, 0, 0, 0, true);
batch.begin();
batch.draw(bgTexture, 0, 0);
batch.draw(passedTexture,
0, 0, 0, 0, camera.getWidth(), camera.getHeight(),
1, 1, 0,
Expand Down

0 comments on commit 51d9859

Please sign in to comment.