Author Topic: Clipping planes and SGL?  (Read 691 times)

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Clipping planes and SGL?
« on: November 25, 2017, 06:32:41 pm »
Sgl has the slWindow function which allows you to select a user clipping plane and local coordinates. It's perfect to allow you to do split screen or not draw where your HUD is, as an example.
But SGL limits you to 2 windows max per draw call, probably for memory reasons.
Of course, it probably also have some impact on the cpu.
I want to set up up to 32 user clipping planes to try something for occlusion culling similar to what the Slavedriver engine did.
I can't seem to find where (or if it's even possible within SGL) I can change the max value or just put a user plane without using the slWindow function.
Is there a way to change this within SGL? Or another function I missed?
If not, where is the window data stored in memory (Before writing to the polygon buffer)?
Thanks!

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Clipping planes and SGL?
« Reply #1 on: November 26, 2017, 07:22:30 pm »
It will be easier to understand with an example. I made a quick video with Quake (with buggy OpenGL rendering) to show what I mean by using clipping planes for occlusion clipping (it helps the GPU only, not the CPU). You can also look under the VDP1 commands in Yabause to see that they keep using User clipping for each quad plane.

https://youtu.be/B4ro-a_aSdg

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Clipping planes and SGL?
« Reply #2 on: November 28, 2017, 03:34:46 am »
I'm doing well with my monologue, so here is a way to have multiple windows if anyone is interrested.
Sadly, I don't think there is a way to disable Z sort within SGL, so the draw command gets sorted according to the distance, which means that it can't really work well unless you create your own rendering code
(which I guess could be done within SGL, but it would be a bit of a pain).


Code: [Select]
SPRITE user_win;
void SET_USER_CLIP(FIXED drawPriority, Sint16 XA, Sint16 YA, Sint16 XC, Sint16 YC)
{
    user_win.CTRL = FUNC_UserClip;
    user_win.XA = XA;  /*Top left pixel*/
    user_win.YA = YA; /*Top left pixel*/
    user_win.XC = XC; /*Bottom right pixel*/
    user_win.YC = YC; /*Bottom right pixel*/
    slSetSprite(&user_win, drawPriority); /* slSetSprite allows you to manually set the draw commands, so you could do anything with it...if there is a way to bypass the Z-sort */
}


« Last Edit: November 28, 2017, 02:02:07 pm by XL2 »

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
SMF spam blocked by CleanTalk