curioustorvald / Terrarum

Modular game engine for a side-scrolling tilemap platformer, and a game that runs on top of it
Other
13 stars 0 forks source link

Glass window is not drawn on top of wall #15

Closed curioustorvald closed 5 years ago

curioustorvald commented 5 years ago

It seems when nontransparent (blockprop-wise) tile is drawn, the wall is not being drawn, or GL mixing is not working there.

curioustorvald commented 5 years ago

It seems the tiling shader (or something else) is just overwriting the window when each layer is drawn.

curioustorvald commented 5 years ago

Currently the render now accepts FBO as an input, and that FBO is the one that the terrain is being drawn. Should be easy right? Blend terrain (a thing drawing now) over the wall (what's on the FBO). But can't get it to work, either my assumption is wrong or I missed a tiny little part, or use multiple FBOs which I want to avoid.

curioustorvald commented 5 years ago

Come and think of it, Torches and Clear Glasses (completely transparent) work, but regular Glass (semitransparent) won't? WTF?

curioustorvald commented 5 years ago

It must be fboRGB_lightMixed.inAction part that something is wrong as using separate FBO for wall and terrain made the same result.

curioustorvald commented 5 years ago

fboRGB itself is okay. Download TGA extractPastebin Base64 (filetype: gz)

Edit: NO it isn't; look at the alpha channel, it should contain no semitransparency but this one does.

curioustorvald commented 5 years ago

Adding more test set FBO and screenshot ZIPPastebin Base64 (filetype: pkzip)

As you can see, alpha channel is not quite right, as if something went wrong in the blending.

Unrelated note: the rim of the Clear Glass is wrong, I should've not put the transparency on the reflection.

curioustorvald commented 5 years ago

Gdx.gl.glBlendEquationSeparate(GL20.GL_FUNC_ADD, GL30.GL_MAX) seems to do the trick, but now Crude Glass look like a sunscreen glass when placed against the open air. Also, use GL30 just for this? It kinda works but not optimal...

Edit: No, it doesn't do a trick.

curioustorvald commented 5 years ago

the separated equation AND setBlendFunctionSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_SRC_ALPHA, GL20.GL_ONE) seems work? (requires newest GDX nightly 20190112)

Then what about alpha premul?

Answer: still need to be premultiplied

curioustorvald commented 5 years ago

now it works without BlendEquationSeparate? What the hell man.

curioustorvald commented 5 years ago

In summary: Using batch.setBlendFunctionSeparate seems to done a trick, and it requires latest GDX build. I'm closing the issue now but if any unintended behaviour occurs, please re-open.