Triangle Drawer for ZScript

Moderator: GZDoom Developers

User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Triangle Drawer for ZScript

Post by Major Cooke »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Triangle Drawer for ZScript

Post by Graf Zahl »

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
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Triangle Drawer for ZScript

Post by Major Cooke »

Oh wow, that's pleasantly surprising to hear! :mrgreen:
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Triangle Drawer for ZScript

Post by Talon1024 »

I'm just curious as to whether the 2D_Refactor branch also means we'll get 3D models in softpoly (again).
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Triangle Drawer for ZScript

Post by Graf Zahl »

No. Apparently dpJudas is working on it again but it is completely separate from the 2D refactor.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: Triangle Drawer for ZScript

Post by Marisa the Magician »

I'm hoping that also means flat/wall sprites working in software too.
dpJudas
 
 
Posts: 3036
Joined: Sat May 28, 2016 1:01 pm

Re: Triangle Drawer for ZScript

Post by dpJudas »

They don't really have anything to do with models.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Triangle Drawer for ZScript

Post by Graf Zahl »

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
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: Triangle Drawer for ZScript

Post by Marisa the Magician »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Triangle Drawer for ZScript

Post by Graf Zahl »

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
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: Triangle Drawer for ZScript

Post by Marisa the Magician »

Is this related to the lack of vector arrays in zscript?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Triangle Drawer for ZScript

Post by Graf Zahl »

No. You could just pass in float arrays with 4 values per vertex.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: Triangle Drawer for ZScript

Post by ZZYZX »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Triangle Drawer for ZScript

Post by Graf Zahl »

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
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: Triangle Drawer for ZScript

Post by Marisa the Magician »

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.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”