0

Im just planing a triangle rasterizer on GPU (GLSL) and I came across an algorithm that could remove barycentric coords (which is quiet expencive to copute) from rasterization.

Given the triangle ABC with the edges abc and the linear equation f. In the first step I check each of the edges abc for intersection with f, (the triangle is already projected in R²) then I take the factor from the linear equation of abc (each edge is an linear equation) and use this parameter in R³ for determinating a new equation which conects the two intersection points on two differnt edges of the triangle. So now I can fill my triangle line by line (the pixels between the intersection points are filled). Based on the linear equation in R³ (of the intersection points) I can now determinate the R³ cooeds of each pixel so I have a depth value.

I know it's a bit complicated so if you have any quaestion please ask me.

So do you think it's possible this way and if yes, is iit faster ?? If I forgot anything or if I did a mistake please inform me. If you have any optimisation idea or something else please inform me.

noName
  • 132
  • 1
  • 9
  • "*barycentric coords (which is quiet expencive to copute)*" ... since when were those expensive? – Nicol Bolas Jan 15 '17 at 23:03
  • "*if yes is iit faster*" Is it faster than what? – Nicol Bolas Jan 15 '17 at 23:07
  • see this QA: [Algorithm to fill triangle](http://stackoverflow.com/a/39062479/2521214) – Spektre Jan 16 '17 at 08:49
  • It is expencive for computing the barycentric coords of the point P in the triangle ABC I have about 36*3+2 calculations, If there is a faster way just add a comment. – noName Jan 16 '17 at 14:40
  • It's not that expensive. The cost is only one addition per pixel in the inner loop. Gradients over a triangle in screen space are linear. Any value within the triangle at point (x, y) has linear correspondence to it's neighbours: e(x + N, y) - e(x + 0, y) can be expressed as constant_over_x * N. Works the same in y direction. It's even cheaper if you use the barycentrics as the edge function so you can solve any gradient by doing dot product with it and the barycentric. – t0rakka Jun 13 '17 at 12:00

1 Answers1

0

I found out that it is a bit faster but I'll have some problems with textures and additionsl calculations would slow the whole thing so I think I will use barycentric coordinates.

noName
  • 132
  • 1
  • 9