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.

DarkBASIC Professional Discussion / Prevent Double Ghosting

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jan 2013 01:10 Edited at: 6th Jan 2013 01:18
My Fog of War effect is achieved by a terrain mesh which is "wrapped" on to the underlying terrain. I then edit the alpha channel of the diffuse values of each vertex in order to make the terrain more or less visible.

Here is the set up routine of the Fog of War object:



In particular, the transparency mode may be relevant, and the fact I disabled zwrite. I tried enabling it again which made it better, but there were still overlaps if viewed from certain angles.

My problem now is that when viewing the terrain from certain angles, the Fog of War object overlaps itself, generating much darker patches than intended. This is visible in the following screen shot: http://forum.thegamecreators.com/xt/xt_apollo_pic.php?i=2423463

How can I fix this?

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th Jan 2013 04:42
Will draw first type functions not help with this? [I can see the issue of cross section type issues]

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 6th Jan 2013 04:57 Edited at: 6th Jan 2013 04:57
Hmm. That sounds like a tricky one because of the mesh not being flat. I guess disabling its ZDepth and flattnining it would work, but I guess that's not what you really want.

I cannot see how you can possibly query whether a given pixel has already been rendered by an object.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jan 2013 12:04
Isn't that what the depth buffer is for? According to the DBP help files, these commands are almost what I need.

enable/disable object zwrite:

Quote: "The Z write state controls whether each pixel of the rendered object writes into the Z depth buffer. The default value is enabled, where the object writes pixels to the Z buffer only when a pixel of the object is successfully rendered to the screen."


enable/disable object zread:

Quote: "The Z read state controls whether each pixel of the rendered object obeys the rule of Z buffer depth culling. The default value is enabled, where the object will only render pixels of the object that are above any previous pixels rendered to the screen."


That last part in bold is the problem. Only pixels above previously rendered pixels are rendered, but there's no way to prevent pixels below later rendered pixels not to be rendered.

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th Jan 2013 21:47
Poke Lee

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 6th Jan 2013 22:16
Lol, who can know but someone upstairs. Who even knows if ZDepth and ZWrite commands even work properly...

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 7th Jan 2013 10:48
The same object will not overlap itself. If this was implemented as a single object then there would be no overlap.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Jan 2013 13:24 Edited at: 7th Jan 2013 13:26
Quote: "The same object will not overlap itself. If this was implemented as a single object then there would be no overlap."


It is a single object (as you can see in the code snippet), and it does overlap itself.

I've enabled zwrite and zread again which seems to prevent most of the errors seen in the screen shot. Now I only get it when viewed from a particular angle. I suppose that will have to do for now if no one else has any suggestions.

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 8th Jan 2013 03:46
Quote: "I've enabled zwrite and zread again which seems to prevent most of the errors seen in the screen shot. Now I only get it when viewed from a particular angle. I suppose that will have to do for now if no one else has any suggestions."


The only thing I could suggest is maybe a different approach altogether. Without knowing the design structure of the game it might be difficult to suggest anything specific.

1. Play with the lighting to create this effect.

2. Play with fog commands or perhaps use a fog shader.

3. Write your own shader that snaps a screen of the fog object and uses it to apply fog as a shader post-process effect.

4. Use a 2D overlay over the screen edges to create a fogging effect.


I know that all sounds easier said then done. But like I said maybe "going back to formula" with your approach will be better.

Login to post a reply

Server time is: 2026-07-07 16:42:52
Your offset time is: 2026-07-07 16:42:52