[Fixed] gl_line_distance_cull

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

gl_line_distance_cull

Postby drfrag » Tue Sep 03, 2019 10:06 am

I've merged the hardware_cull branch (gl_line_distance_cull CVAR) from QZDoom and it works with a huge performance increase but there's a problem. On very big maps the sky dissapears (black) when looking at the big part of the level (e.g. facing east in Planisphere 2).
@dpJudas @Rachael @Graf Zahl @realdevs:
Any idea of what's going on? Could be a limitation of the clipper? :3:

https://github.com/madame-rachelle/qzdo ... dware_cull
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: gl_line_distance_cull

Postby Graf Zahl » Tue Sep 03, 2019 10:42 am

Skies are being drawn as part of the outer wall they are on. Since you cull the wall you also cull the sky - and if no linedef with a sky remains, nothing will be drawn instead.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: gl_line_distance_cull

Postby drfrag » Tue Sep 03, 2019 11:40 am

I see, then i guess it's not fixable. It only happens on certain maps when facing certain directions, for instance on MAP15 it doesn't.
In software it was not a problem since you filled the gaps with the sky or the floor (memcpy) or else you'd get HOMs.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: gl_line_distance_cull

Postby Graf Zahl » Tue Sep 03, 2019 12:38 pm

If you want distance culling you have to close the gaps, otherwise stuff will look broken. And if you cull the back of a linedef whose front side has a sky, you have to let the renderer process the sky. If you want to get the same behavior as the software renderer you have to draw a horizon on the linedef.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: gl_line_distance_cull

Postby drfrag » Tue Sep 03, 2019 1:24 pm

Thanks. But easier said than done. :?
If i try to do that everything dissapears.
Code: Select allExpand view
inline bool IsDistanceCulled(seg_t *line)
{
   double dist3 = gl_line_distance_cull * gl_line_distance_cull;
   if (dist3 <= 0.0)
      return false;

   double dist1 = (line->v1->fPos() - r_viewpoint.Pos).LengthSquared();
   double dist2 = (line->v2->fPos() - r_viewpoint.Pos).LengthSquared();
   if ((dist1 > dist3) && (dist2 > dist3))
   {
      if (line->frontsector->GetTexture(sector_t::ceiling) == skyflatnum)
      {
         line->linedef->special = Line_Horizon;
      }
      return true;
   }
   return false;
}
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: gl_line_distance_cull

Postby Graf Zahl » Tue Sep 03, 2019 1:42 pm

You are not supposed to turn the line into a horizon but to treat it like one when during rendering you find out that it is the place where culling takes place.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: gl_line_distance_cull

Postby drfrag » Wed Sep 04, 2019 2:43 am

Thanks but again sorry easier said than done. :?
How? Calling Skyplane? Both Skyplane and Skynormal are private in GLWall.
The culling takes place here in GLSceneDrawer::AddLine:
Code: Select allExpand view
   if (IsDistanceCulled(seg))
   {
      if (seg->frontsector->GetTexture(sector_t::ceiling) == skyflatnum)
      {
         GLWall wall(this);
         wall.SkyPlane(seg->frontsector, sector_t::ceiling, false);
      }
      clipper.SafeAddClipRange(startAngle, endAngle);
      return;
   }
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: gl_line_distance_cull

Postby Graf Zahl » Wed Sep 04, 2019 3:26 am

You have to go through GLWall's main process function but have to make adjustments that it properly recognizes this case.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: gl_line_distance_cull

Postby drfrag » Wed Sep 04, 2019 5:26 am

Thanks very much! It's fixed now. :) I should fill the gaps anyway with the ceiling texture.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: gl_line_distance_cull

Postby drfrag » Wed Sep 04, 2019 11:58 am

Done. I've pushed the changes here: https://github.com/drfrag666/gzdoom/com ... 4e655128f1
It works well now however with low values some strange things happen, such as this line being culled intermitently from that sector on MAP23 when looking around.
Screenshot_Doom_20190904_200305.png
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: gl_line_distance_cull

Postby drfrag » Thu Sep 05, 2019 5:21 am

I know what's going on, a line behind is being culled and when i draw on that line the texture can be seen since there's no mid texture on the front line, that wall is supposed to open later. I don't think there's a solution since it's a different line. >:(
Edit: no, it's the line itself. It's being culled intermitently. No idea of what's going on with that line. Same happens in MAP20.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: gl_line_distance_cull

Postby drfrag » Thu Sep 05, 2019 11:23 am

The position of the vertexes changes when you look around in hardware so for low cull distances even a line close to you can be culled. There's no workaround.
I've added sprite culling too and it certainly has an impact on performance.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests