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.

Dark GDK / Particle problems

Author
Message
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Oct 2010 04:13
Here is a screen shot with problem descriptions. The particles are instanced planes with a flare texture using an alpha channel. The example uses Evolved's water.fx. If I create the water, I get the extra texture stage problem. The transparency issue is constant reguardless of the water. My next post will be the source code. Please test it out and give me ideas how to fix it.

The fastest code is the code never written.

Attachments

Login to view attachments
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Oct 2010 04:18 Edited at: 8th Oct 2010 04:19
Here is the source:

Sorry it's SO BIG.

The fastest code is the code never written.

Attachments

Login to view attachments
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 8th Oct 2010 06:56
The issue is to do with draw order, the short answer is to 'dbDisableObjectZWrite()' on everything that's transparent.

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Oct 2010 15:59
I think I tried 'dbDisableObjectZWrite()', but I'll give it another shot.

About the texture stage bleeding thru: The water object has multiple texture stages. The flares should only have the first stage active. It seems the engine is not disabling the stages past stage0 when rendering the flares. I tried
dbTextureObject(flare,1,NULL);
This would (in directx terms) disable stages 1-7. It didn't work, so here I am with questions that I should be able to figure out but for some reason the things I try don't work at all.

The fastest code is the code never written.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 8th Oct 2010 16:48
It doesn't work because the issue has nothing to do with texture stages, it's a draw order issue. Your particles are currently writing to the Z-Buffer, and because some of the closer ones are being drawn before the more distant ones, this causes the transparent items behind it to fail the pixel depth test, thus are partially or wholly never drawn.

So you need to force your transparent particles to render last, to do this you need to enable a transparency mode that sorts them as such, one mode to do this is mode 2, so add: 'dbSetObjectTransparency(i, 2);' in your particle creation loop, make sure it's applied to all instances.

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Oct 2010 16:57
I tried that. I tried ALL the modes (0-6). 0 gives no transparency, 1-3 gives transparency, 4 makes them disappear(because they are too transparent and fail the 0x000cf test), 5 is supposed to be depth tested but doesn't seem to do anything but give the same result as 1-3, and 6 (I don't remember what it did but it didn't give the results I wanted).

The fastest code is the code never written.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 8th Oct 2010 17:49
You're sure you called that for all your particles? i.e. like this:



Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Oct 2010 18:34
I will try that when I get home. I thought since the other texturing information for an instanced object was handled by the source object, this would also.

The fastest code is the code never written.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Oct 2010 20:25
Ok. I changed my particle generation to read:

This fixed the transparency issue (mostly). It's still not perfect. May be because I have so many particles and the engine has to divide it up and that causes some of them to not render in the correct order. It's MUCH better though.

Now I still have the same problem with the texture stage "bleed over". Any thoughts?

The fastest code is the code never written.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 9th Oct 2010 05:11
Why do you keep using transparency mode 5? 2 looks fine to me.

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 9th Oct 2010 20:53
2 seems to give the same result as 5, but 5 is supposed to do depth-checking.... I don't think it works right. In my previous post I said it fixed it. I was wrong. It's still doing the same thing. I decided to use spheres for my particles. This gives me an advantage over the billboards-- I don't have to point them at the camera. I actually get better performance using "dbMakeObjectSphere(i,0.5,8,8);". The 8,8 gives me plenty of detail concidering the spheres are so small.

I know exactly what is happening with the "bleed over". It's the water. The water is being rendered last. This means anything below the waterline that would normally be hidden is visible to the particles and is therefore being blended with the particle's texture. So basically the particles don't "see" the water.
Any thoughts?

The fastest code is the code never written.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 9th Oct 2010 20:59 Edited at: 9th Oct 2010 21:00
I don't know what you're expecting to see, but with the modifications I mentioned, I see this:



Attachments

Login to view attachments
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 9th Oct 2010 21:42
Check this out. I need a way to make sure the particles are drawn last.

The fastest code is the code never written.

Attachments

Login to view attachments
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 10th Oct 2010 05:07
Can you attach your current project so I can see that for myself?

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 10th Oct 2010 05:19 Edited at: 10th Oct 2010 05:20
I'll give you the whole thing:


Oh, my default resolution is 1080p. You may want to change it before running it.

The fastest code is the code never written.

Attachments

Login to view attachments
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 10th Oct 2010 05:35
It works fine if I ghost all of your particles, for some reason not all attributes are copied when you instance an object so make sure it's outside the condition:



Also, your water object isn't transparent so you shouldn't give it a transparency flag(though in this particular case it doesn't seem to affect the result).

You can also get the desktop resolution using the following:



Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 10th Oct 2010 17:02
I was wondering where the desktopwidth(),desktopheight() went to... Thanks.

The ghosting of each object works great except it costs me frame rate.... I guess I'll have to deal with it unless you have a better alternative.

The fastest code is the code never written.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 10th Oct 2010 17:09
Quote: "I guess I'll have to deal with it unless you have a better alternative."


Don't use spheres? Use a single object? Use point sprites?

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 10th Oct 2010 18:06
I'll give it a shot. On my "point sprites" thread, I was given the impression that I would have to abandon GDK to do point sprites.... Maybe I read your post wrong. I'll look into it further and maybe find some examples to play with. I'll post when I have trouble.

Thanks.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-06-30 11:21:11
Your offset time is: 2024-06-30 11:21:11