Conversation started Jul 14, 2016 at 1:12.
Jul 14, 2016 01:12
Oh, are you doing alpha blending manually?
Ohhhhh, duh.
this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
this.gl.enable(this.gl.BLEND);
You're using Z buffering for the asteroids, don't do that :P
o :P
how would one fix that?
What's happening is that the ones that "override" are being drawn first
Jul 14, 2016 01:13
They punch out the depth in that spot, and so the one drawn next gets cut by the Z-buffer
So still, "you forgot to set up alpha testing" lol
disabling GL_DEPTH_TEST would be a better way to deal with it though
but once you do that, you should still use alpha testing for pixel fillrate reasons
o lol I disable my depth_test, all good now :D
@MickLH tyvm Mick! ;D
@MickLH I'll look into that
@TheMuffinCoder enable GL_ALPHA_TEST
You should probably disable GL_ALPHA_BLEND just for debugging, to see what you're doing
the alpha test alone won't do anything yet, you need to also call glAlphaFunc()
I dont think webgl has ALPHA_TEST
4
Q: AlphaFunctions in WebGL?

MarkusIs it possible to achieve an transparency effect where fragments with alpha lower than 0.5 are discarded and fragments with alpha higher than 0.5 are rendered rendered opaque? From what I've read, glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5); would be what I'm looking for but unfort...

Nvm :P
Jul 14, 2016 01:18
it had better have it :P it's like one of the oldest things
But before I modify my shaders, it works now :D Thanks Mick! :D
@TheMuffinCoder you should set up an ugly background where you can see the whole square of the sprite
and then make sure that glAlphaFunc(GL_LEQUAL, 0.0); kills the right pixels
ooo ty ty ty Mick
This is all valuable gl info :D
when you kill them that way, you don't have to pay fragment shader and fillrate cost for them
and when you disable the Z-buffer there is a savings, using depth buffering makes every pixel cost more fillrate
and you might be tempted to think "it's just 2D, it'll be fine" but actually fill rate is usually what gets used up first
and a 2D app has just as many pixels to fill as a 3D app
and, a 2D app is usually in an even worse situation because there's so much alpha blending and so much overdraw (drawing one thing, then drawing something else over top of it)
Disabled gl.Blend just to see how it looked and its scary :P
Jul 14, 2016 01:23
Ok, so now if you set up alpha testing right, it should mostly look right, except the borders
the borders will be ugly AF, don't worry about that
Those pixels need full alpha blending, is why
if(gl_FragColor.a < 0.5) {

    discard;

 }
Added this to my fragment shader and now it's perfect! :D
use a smaller number
Do you have any to recommend?
<= 0.0
it could go negative? o.O
Jul 14, 2016 01:26
no, but it can be exactly zero
I just like to use <= because it feels like it'll really catch the fuck out of that zero
I'm always scared of == on the GPU, it never works right unless you beg it to
anything above zero technically needs alpha blending to get the right result
The borders look awful now but now I can enable gl.blend again right?
yeah that's how it should go
it mostly works, except the borders, right?
Jul 14, 2016 01:28
protip: You can use the < 0.5 mode and disable alpha blending for "Low End Settings" mode
 
Conversation ended Jul 14, 2016 at 1:28.