Some way for sector skies to avoid being affected by SSAO

Like feature suggestions, but you've actually written code to make it happen. More likely to make it into the game than some random request in feature suggestions.

Moderator: GZDoom Developers

Forum rules
Please see Code submission guidelines

GZDoom Status:
Image

Legacy Status:
Image Image

QZDoom Status:
Image

Some way for sector skies to avoid being affected by SSAO

Postby Marisa Kirisame » Wed Dec 25, 2019 4:58 am

I'm getting frustrated with the amount of complaints I get about this. My usual suggestions to work around this (use GLDEFS skyboxes, or if you need a specific shape use a model with translucency and an alpha of 0.999999) are rejected because it's "too much work".

Can't we just get a MAPINFO flag that makes AO on portals not affect sky viewpoints?

Edit: I'm implementing this myself if necessary.

Edit 2: Wow this needed way less work than I imagined. The thing now is... should it be a flag to disable skybox ao or to enable it? Think I'll go with the latter seeing as the vast majority of mappers would probably want it that way.

The only catch with how I'm doing this is that stacked sectors report themselves as being skies, so they're also affected.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Graf Zahl » Wed Dec 25, 2019 6:07 am

Stacked sectors report themselves as a different kind of portal, what did you check?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Some way for sector skies to avoid being affected by SSA

Postby Marisa Kirisame » Wed Dec 25, 2019 6:12 am

Just the IsSky() virtual.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Tormentor667 » Wed Dec 25, 2019 8:54 am

Marisa Kirisame wrote:Edit 2: Wow this needed way less work than I imagined. The thing now is... should it be a flag to disable skybox ao or to enable it? Think I'll go with the latter seeing as the vast majority of mappers would probably want it that way.

As a lot of maps and mods already use sector skyboxes I’d suggest that as well.
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany

Re: Some way for sector skies to avoid being affected by SSA

Postby Marisa Kirisame » Thu Dec 26, 2019 2:16 am

The PR is live, moving this to code submissions.
Last edited by Rachael on Thu Dec 26, 2019 2:17 am, edited 1 time in total.
Reason: fixed link (it 404'd)
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Rachael » Thu Dec 26, 2019 2:19 am

Since it uses the IsSky() virtual to check, it also affects stacked sectors due to them technically reporting themselves as skies. I have not found a way around this.


This is the biggest issue I see with this, and probably why it was not done so quickly, previously. I don't know how involved it will be to check for a stacked sector, but this could be important.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Graf Zahl » Thu Dec 26, 2019 2:26 am

You have to check the actual portal type which is unambiguous.

Code: Select allExpand view
//============================================================================
//
// All information about a sector plane portal
//
//============================================================================

enum
{
   PORTS_SKYVIEWPOINT = 0,      // a regular skybox
   PORTS_STACKEDSECTORTHING,   // stacked sectors with the thing method
   PORTS_PORTAL,            // stacked sectors with Sector_SetPortal
   PORTS_LINKEDPORTAL,         // linked portal (interactive)
   PORTS_PLANE,            // EE-style plane portal (not implemented in SW renderer)
   PORTS_HORIZON,            // EE-style horizon portal (not implemented in SW renderer)
};

enum
{
   PORTSF_SKYFLATONLY = 1,            // portal is only active on skyflatnum
   PORTSF_INSKYBOX = 2,            // to avoid recursion
};

struct FSectorPortal
{
   int mType; <------------- here
   int mFlags;
};
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Some way for sector skies to avoid being affected by SSA

Postby Marisa Kirisame » Thu Dec 26, 2019 2:46 am

Found a way to access that, although it's not very pretty and I have no idea if what I'm doing is "correct", I've swapped the
Code: Select allExpand view
!di->mCurrentPortal->IsSky()

line with a
Code: Select allExpand view
!di->mCurrentPortal->lines[0].secportal->mType==PORTALTYPE_SKYBOX


Unfortunately this seems to be wrong because now ALL portals have no AO.

Edit: Wait, I've got a lot of stuff mixed up here.

Edit 2: Feck's sake, the solution was staring me in the face all this time. There's a GetName() function that will tell you what the portal is. I've replaced the line with:
Code: Select allExpand view
applySSAO = (strcmp(di->mCurrentPortal->GetName(),"Skybox") || di->Level->flags3&LEVEL3_SKYBOXAO);

Surprising that that function that mainly exists for debugging came in handy here.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Graf Zahl » Thu Dec 26, 2019 3:16 am

Don't use that GetName function for any kind of decision making. Use the flags. The name is merely for printing diagnostics.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Some way for sector skies to avoid being affected by SSA

Postby Marisa Kirisame » Thu Dec 26, 2019 3:21 am

OK, but the alternative to that is horrendously ugly and involves casting void* to something else and crossing my fingers that it works.

I'm no C++ expert here, so this will take me a while to figure out.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Graf Zahl » Thu Dec 26, 2019 3:40 am

What do you mean with casting void*?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Some way for sector skies to avoid being affected by SSA

Postby Marisa Kirisame » Thu Dec 26, 2019 3:46 am

I figured that the alternative here is to use the GetSource() function which returns void*. In the case of skybox portals it's a pointer to a FSectorPortal.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Graf Zahl » Thu Dec 26, 2019 3:53 am

Ok. But I think this needs to be done differently anyway. The decision whether to apply SSAO must be done by the portal setup code in hw_walls.cpp/PutPortal, where you still have access to this stuff, not the actual portal renderer itself. Imagine you want to add some options later - it's going to be quite complicated as you already noticed that you do not have all info at hand anymore.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Some way for sector skies to avoid being affected by SSA

Postby Marisa Kirisame » Thu Dec 26, 2019 4:18 am

OK. Then I think I'll leave this work to someone else.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Some way for sector skies to avoid being affected by SSA

Postby Chris » Thu Dec 26, 2019 11:36 am

Marisa Kirisame wrote:Found a way to access that, although it's not very pretty and I have no idea if what I'm doing is "correct", I've swapped the
Code: Select allExpand view
!di->mCurrentPortal->IsSky()

line with a
Code: Select allExpand view
!di->mCurrentPortal->lines[0].secportal->mType==PORTALTYPE_SKYBOX


Unfortunately this seems to be wrong because now ALL portals have no AO.

You left in the !, so it's checking if mType is false is equal to PORTALTYPE_SKYBOX.
User avatar
Chris
 
Joined: 17 Jul 2003

Next

Return to Code Submissions

Who is online

Users browsing this forum: No registered users and 0 guests