[Added] Triangle Drawer for ZScript

Moderator: GZDoom Developers

Triangle Drawer for ZScript

Postby Major Cooke » Sat Apr 07, 2018 1:38 pm

Seeing a sudden and vibrant flash of majestic rainbow that is the 2D_Refactor branch, I figured now's a potentially good time to bring this up again.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Triangle Drawer for ZScript

Postby Graf Zahl » Sun Apr 08, 2018 12:59 am

This was actually the main motivation to clean up that code. Having to implement this 4 times in the different 2D rendering backends was simply an unpalatable proposition. Now with only one backend that is actually clean enough to work with it is an entirely different thing.

All in due time, though. First the thing must be working on all supported hardware and the inevitable kinks be ironed out before we start thinking about new features.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Triangle Drawer for ZScript

Postby Major Cooke » Sun Apr 08, 2018 8:05 am

Oh wow, that's pleasantly surprising to hear! :mrgreen:
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Triangle Drawer for ZScript

Postby Talon1024 » Tue Apr 10, 2018 1:52 am

I'm just curious as to whether the 2D_Refactor branch also means we'll get 3D models in softpoly (again).
Talon1024
 
 
 
Joined: 27 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Triangle Drawer for ZScript

Postby Graf Zahl » Tue Apr 10, 2018 1:59 am

No. Apparently dpJudas is working on it again but it is completely separate from the 2D refactor.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Triangle Drawer for ZScript

Postby Marisa Kirisame » Tue Apr 10, 2018 5:49 am

I'm hoping that also means flat/wall sprites working in software too.
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
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: Triangle Drawer for ZScript

Postby dpJudas » Tue Apr 10, 2018 5:55 am

They don't really have anything to do with models.
dpJudas
 
 
 
Joined: 28 May 2016

Re: Triangle Drawer for ZScript

Postby Graf Zahl » Tue Apr 10, 2018 6:20 am

No, but theoretically they could be handled by the same code if a fake square model is created on the fly for it, provided that the model code handles the depth sorting in a way that makes it possible.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Triangle Drawer for ZScript

Postby Marisa Kirisame » Thu Jun 07, 2018 2:14 pm

I think it's time to revive this thread. Now that the 2D refactor has made things much cleaner, I decided to try again.

Results are on this branch right now. I'm also going to link an example zip here showing one of the many things this could be used for: on-screen rotated graphics.

At the moment, I'm trying to figure out how to best approach handling all the scaling parameters, so for now the vertex positions are in absolute screen coords.

If I manage to get this to work 100%, I think psprite drawing could be moved to it, which would easily allow arbitrary scaling and rotation of weapon sprites.
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
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: Triangle Drawer for ZScript

Postby Graf Zahl » Thu Jun 07, 2018 2:19 pm

The main reason I haven't done anything myself yet is because there should be a way to draw multiple triangles with one call which would necessitate passing an array to the function.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Triangle Drawer for ZScript

Postby Marisa Kirisame » Thu Jun 07, 2018 2:28 pm

Is this related to the lack of vector arrays in zscript?
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
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: Triangle Drawer for ZScript

Postby Graf Zahl » Thu Jun 07, 2018 3:07 pm

No. You could just pass in float arrays with 4 values per vertex.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Triangle Drawer for ZScript

Postby ZZYZX » Thu Jun 07, 2018 3:12 pm

Passing an array can probably be done by having a dynamic array of Vertex class wrapped in a VertexArray or VertexBuffer class, thus one can pass VertexBuffer to the drawer function. I don't particularly like this hack though, easier to just draw single triangle.

Even Doom2016 (according to render pipeline reverse engineering) doesn't optimize UI calls and just draws one drawcall per item :P
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: Triangle Drawer for ZScript

Postby Graf Zahl » Thu Jun 07, 2018 3:45 pm

GZDoom actually does merge successive compatible items. My concern is more with the overhead of the parameter parser and drawlist generator that needs to run for each single triangle.
But your suggestion isn't that bad actually. Having a VertexArray class that can be passed would give users the option to add some custom processing in child classes and if access to the vertex data is made virtual even allow to program some generator classes that do not have to explicitly store each vertex.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Triangle Drawer for ZScript

Postby Marisa Kirisame » Sun Jun 10, 2018 2:05 pm

I've replaced the single triangle drawing with "shape" drawing, which uses a "Shape2D" class containing arrays for vertices, coords and indices for triangles. On the ZScript side all that's available are some functions for sending data and clearing the arrays. If ZScript had Vector dynamic arrays I wouldn't really need that intermediate class, but that's how it is.

An updated version of the test zip is here. I'd say the setup is a bit cleaner now, though at this tiny scale there's not much of a difference in performance. I should bake up something with a larger scale.

I have opened a PR now. In the end I went with the shape version.
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
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

Next

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 3 guests