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

Fix transparency for FSprites #1159

Conversation

BioRyajenka
Copy link
Contributor

Honestly I am not quite sure what this line does, but without it transparency work as expected.
Fixes #965

@soywiz
Copy link
Member

soywiz commented Dec 22, 2022

@BioRyajenka

fun DO_OUTPUT_FROM(builder: Program.Builder, out: Operand, u_OutputPre: Operand = BatchBuilder2D.u_OutputPre) {
builder.apply {
// We come from premultiplied, but output wants straight
IF(u_OutputPre.not()) {
SET(out["rgb"], out["rgb"] / out["a"])
}
}
}

Basically, input and output of shaders before supported input and outputs with premultiplied & straight alphas.
Now shaders are expected to use colors with premultiplied alpha always. The thing is that when rendering to the final output buffer, it was with straight alpha, though in most cases final render buffer alpha will be 1.0 always. I wanted to use an intermediate texture to simplify shaders and always use premultiplied for input and output, but that work was not completed

@soywiz
Copy link
Member

soywiz commented Dec 22, 2022

@BioRyajenka thanks! I have done the full cleanup now in #1162 . I have also updated tests with ./gradlew jvmTestFix. Please check with your code if the premultiplied alpha issue is fixed with that PR too.

@soywiz soywiz closed this Dec 22, 2022
@BioRyajenka BioRyajenka deleted the feature/fix-transparency-for-fsprites branch December 22, 2022 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems with blending in FSprites
2 participants