Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 3D particles - BUG

Author
Message
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 9th Sep 2019 20:21
Hi there.

This is the first time I've played with 3D particles, but there's some depth issues with multiple emiters. See the attached screen shot....some particles correctly draw in front of others according to depth, but some randomly draw in front of those they are behind. These all have transparency which is likely the problem, but it doesn't happen withh all of them for some reason.

Attachments

Login to view attachments
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 9th Sep 2019 20:26
Here's a quick video of it in action....you can see sometimes the particles are drawn properly, sometimes they are not.

Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 10th Sep 2019 20:31
Paul,

On further testing it *seems* to be that the particles don't depth write correctly on their called face....or reverse side. So if I drop four stacks of smoke in a square pattern, they all draw correctly from one side, then not from the other.

Might be conincidence, but seems to be what's happening.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 10th Sep 2019 21:15
Though actually.....they also don;t play nice with any other transparent surface, for example the water surface....placing one under it just draws it over the top.
GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 10th Sep 2019 23:38 Edited at: 10th Sep 2019 23:44
Quote: "On further testing it *seems* to be that the particles don't depth write correctly on their called face..."


You are using alpha blending, they can't depth write. Why they sometimes appear correct is because depending on your view angle sometimes the overlapping ones coincidentally get drawn in the correct order. In your case the errors are only clearly visible for a tiny fraction of them anyway (when grey ones overlap brown ones), so a lot of it seems correct even if it's maybe not (grey over grey).
There is no good solution other than either sorting the drawing order of the alpha blended polies or taking a deep dive and implementing a custom solution for order-independent transparency. (there are several different approaches)
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 11th Sep 2019 00:09
Hmmm......but they are particles, so we dont actually have that much control over them. Not tried a different blending mode though, will need to try that.
GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 11th Sep 2019 00:53 Edited at: 11th Sep 2019 00:54
Assuming each emitter you have has a different particle ID, you could try using Draw3DParticles(ID) in a specific order based on each emitter's distance from the cam. If you only have a few emitters sorting shouldn't have a big impact.
You'd just have to make sure they don't already get drawn in the main render process. (hide them and then draw them manually after the main render).
It's not perfect and won't sort particles of the same emitter, but at least the obvious grey over brown things should be gone where different emitters overlap.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 11th Sep 2019 01:14
Yeah......but then they'll also draw over the top of objects in front of them, if they are drawn outside the main draw call.

I actually thought of something else.....if paul shared the stock particle shader code (it uses instances objects so it wont be like the others) then let us assign a shader to particles, I could then code around the transparency. All I want to do is drop out the black background......and as I type I'm now wondering if setting a transparent colour on the image would work with a particle?

That's def worth trying.

Either way, particles dont work very well right now if they have to have, or be near, anything transparent, which makes them not useless, but less appealing and not how they should work.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 11th Sep 2019 02:00
It doesn't work.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 11th Sep 2019 03:28
does SetObjectDepthWrite(obj.ID,1) work with particles ?
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 11th Sep 2019 08:02
Given that they aren't an object, I very much doubt it. I'm not sure that would even work at all, given they are essentially an instanced plane.

Login to post a reply

Server time is: 2024-11-22 17:18:40
Your offset time is: 2024-11-22 17:18:40