got a scaling window going, yay
-
@bnut the right can be skipped because you know when you've recorded coverage, so once you find a blank tile after you've had any coverage you know there are no more tiles in that row. the only way to do the left would be to iterate backwards and then you'd have the same problem on the right
the other option is to have an edge walking algorithm and that could actually be slower since this just steps through the bounding box in chunks
-
@bnut the right can be skipped because you know when you've recorded coverage, so once you find a blank tile after you've had any coverage you know there are no more tiles in that row. the only way to do the left would be to iterate backwards and then you'd have the same problem on the right
the other option is to have an edge walking algorithm and that could actually be slower since this just steps through the bounding box in chunks
@bnut you could conceivably do the same thing with the bottom edges but you'd have to step vertically in your inner loops which could trash cache locality
-
@eniko every time I start a game project (and never finish) I think about: what if it was software rasterized?
software rasterization just has something to it.
-
-
@bnut hm, interesting thought!
-
-
@bnut hm, interesting thought!
@bnut i think the calculations for all the weights/attribute values for each edge tile might still be more expensive than just stepping
-
wake up babe hierarchical tiled triangle rasterizer just dropped
each meta tile is 4x4 tiles which are 8x8 pixels. magenta and red tiles are blank meta and normal tiles, white and cyan are fully covered meta and normal tiles
@eniko why stop at 4x4? - or rather, why two fixed levels rather than a full quad-tree structure?
-
@eniko why stop at 4x4? - or rather, why two fixed levels rather than a full quad-tree structure?
@eniko btw, for the corners between tiles, do you test that point 4x per triangle edge (once for each neigboring tile) or can you share the result between tiles?
-
@bnut this isn't lerping anything. it calculates all the stepping increments once up-front and then does addition across the entire bounding box to get the weights and attribute values
i guess maybe you could step them along with the bresenham? 🤔
-
@eniko btw, for the corners between tiles, do you test that point 4x per triangle edge (once for each neigboring tile) or can you share the result between tiles?
@nicklockwood you can share the result but i'm not, since calculating the corners is only 3 additions and most of the work is in checking them all together, and sharing the corners is more bookkeeping and would make fully covered tiled a little less common
-
now i need to convert it from floating point to fixed point and i'll be mostly done with the optimizing stage. then i'll add some different rendering options (it just does flat and gouraud atm) and put it on github
@eniko is the gourard shading just bilinear interpolation of vertex colors supplied by the caller, or do you actually have a lighting model on top?
And if so, what do you do in flat shading mode if a triangle has different vertex colors?
-
@bnut that could work 🤔
i've done a lot of work on this and am ready to stop though so i'm not gonna try it >_>
-
@eniko why stop at 4x4? - or rather, why two fixed levels rather than a full quad-tree structure?
@nicklockwood it's harder to write a generic dynamically sized hierarchical system that's also fully optimized. also, at 32x32 even at 8k resolution that's only 240x135 meta tiles, so i'm not sure it has a ton of advantage
-
@eniko is the gourard shading just bilinear interpolation of vertex colors supplied by the caller, or do you actually have a lighting model on top?
And if so, what do you do in flat shading mode if a triangle has different vertex colors?
@nicklockwood it's just bilinear interpolation. the way it works is that vertices can have any number of interpolated attributes, so in gouraud it has r, g, and b attributes. in flat color mode it doesn't actually step the attributes at all and just pipes the color value straight through
-
@bnut a simpler optimization would be to count left sided vs right sided verts and switch iteration direction based on that
-
now i need to convert it from floating point to fixed point and i'll be mostly done with the optimizing stage. then i'll add some different rendering options (it just does flat and gouraud atm) and put it on github
ok ok one more. i'm checking right sidedness by counting vertices on the right side of the bounding box center, and if it is a right sided triangle i change the horizontal tile iteration from left-to-right to right-to-left
so now the left image's triangle doesn't do a bunch of extra work
-
ok ok one more. i'm checking right sidedness by counting vertices on the right side of the bounding box center, and if it is a right sided triangle i change the horizontal tile iteration from left-to-right to right-to-left
so now the left image's triangle doesn't do a bunch of extra work
@eniko This reminds me so much of a book I still have somewhere with assembly drawing routines from the demo scene of the late 90s.
Pro: taught me how to rasterize a curved line.
Con: I forgot everything.
I also don't remember the target platform.