I am coding the rasterization of triangles by the baricentric coordinate method.
Look a lot of code and tutorials that are on the web about the optimization of this algorithm.
I found a way to optimize it that I did not see it anywhere.
I Only code the painting of triangles without Zbuffer and without textures. I am not comparing speeds and I am not interested in doing them, I am simply reducing the amount of instructions that are executed in the internal loop.
The idea is simple, someone must have done it before but he did not publish the code or maybe in hardware it is already that way too.
It should be noted that for each horizontal line drawn, of the three segments, you only need to look at one when going from negative to positive to start drawing and you only need to look at one when it goes from positive to negative when you stop drawing.
I try it and it works well, now I am implementing a regular version with texture and zbuffer to realize how to add it to this optimization.
Does anyone know if this optimization is already done?
The code is in https://github.com/phreda4/reda4/blob/master/r4/Dev/graficos/rasterize2.txt
From line 92 to 155
↧