Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly clear the alpha discard param in IconComponent & QuadBackgroundComponent #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Version 1.16.1 (unreleased)
* Added a Panel(ElementId) constructor.
* Slight change to popup layer placement to only move out and never in
even if the calculated popup z-offset is positive.
* Properly clear alpha discard param in QuadBackgroundComponent and
IconComponent when alpha discard is disabled (is set to 0).


Version 1.16.0 (latest)
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/simsilica/lemur/component/IconComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ public void setAlphaDiscard( float alphaDiscard ) {
}
this.alphaDiscard = alphaDiscard;
if( material != null ) {
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
if( alphaDiscard == 0 ) {
material.getMaterial().clearParam("AlphaDiscardThreshold");
} else {
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
}
}
}

Expand Down Expand Up @@ -448,7 +452,9 @@ protected void createIcon() {
material.setTexture(image);

material.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
if( alphaDiscard > 0 ) {
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
}
}

icon.setMaterial(material.getMaterial());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ public void setAlphaDiscard( float alphaDiscard ) {
}
this.alphaDiscard = alphaDiscard;
if( material != null ) {
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
if( alphaDiscard == 0 ) {
material.getMaterial().clearParam("AlphaDiscardThreshold");
} else {
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
}
}
}

Expand Down Expand Up @@ -274,7 +278,9 @@ protected void createMaterial() {
material.setTexture(texture);
}
material.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
if( alphaDiscard > 0 ) {
material.getMaterial().setFloat("AlphaDiscardThreshold", alphaDiscard);
}
}

protected void refreshBackground( Vector3f size ) {
Expand Down