Triangle Drawer for ZScript

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Triangle Drawer for ZScript

Re: Triangle Drawer for ZScript

by Marisa the Magician » Tue Jul 17, 2018 1:13 am

Hey can we get this thread closed as added?

Re: Triangle Drawer for ZScript

by Marisa the Magician » Sun Jun 10, 2018 1: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.

Re: Triangle Drawer for ZScript

by Graf Zahl » Thu Jun 07, 2018 2: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.

Re: Triangle Drawer for ZScript

by ZZYZX » Thu Jun 07, 2018 2: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

Re: Triangle Drawer for ZScript

by Graf Zahl » Thu Jun 07, 2018 2:07 pm

No. You could just pass in float arrays with 4 values per vertex.

Re: Triangle Drawer for ZScript

by Marisa the Magician » Thu Jun 07, 2018 1:28 pm

Is this related to the lack of vector arrays in zscript?

Re: Triangle Drawer for ZScript

by Graf Zahl » Thu Jun 07, 2018 1: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.

Re: Triangle Drawer for ZScript

by Marisa the Magician » Thu Jun 07, 2018 1: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.

Re: Triangle Drawer for ZScript

by Graf Zahl » Tue Apr 10, 2018 5: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.

Re: Triangle Drawer for ZScript

by dpJudas » Tue Apr 10, 2018 4:55 am

They don't really have anything to do with models.

Re: Triangle Drawer for ZScript

by Marisa the Magician » Tue Apr 10, 2018 4:49 am

I'm hoping that also means flat/wall sprites working in software too.

Re: Triangle Drawer for ZScript

by Graf Zahl » Tue Apr 10, 2018 12:59 am

No. Apparently dpJudas is working on it again but it is completely separate from the 2D refactor.

Re: Triangle Drawer for ZScript

by Talon1024 » Tue Apr 10, 2018 12:52 am

I'm just curious as to whether the 2D_Refactor branch also means we'll get 3D models in softpoly (again).

Re: Triangle Drawer for ZScript

by Major Cooke » Sun Apr 08, 2018 7:05 am

Oh wow, that's pleasantly surprising to hear! :mrgreen:

Re: Triangle Drawer for ZScript

by Graf Zahl » Sat Apr 07, 2018 11:59 pm

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.

Top