From: Brian Paul <brianp@vm...>  20100126 21:07:16

Martijn Sanderse wrote: > Hi, > > I'm pretty new to OpenGL and Mesa (I am reading my redbook...). If I > picked the wrong place for my question, please let me know. > > I'm trying to find out whether I can use mesa for rendering polygons > to offscreen images. In particular I'm interested in the accuracy of > the antialiasing routines. > > To find out I followed the example in > MesaDemos/progs/osdemos/osdemo32.c. I changed the function > render_image() to the one described below. I basically draw a simple > polygon with three vertices. > > Because the top vertex of my polygon is almost flat, but not entirely, > I expect (theoretically) to find a row with increasing pixel values > in the buffer. However, the total number of unique pixel values is 23 > at maximum. I inspect only the "R" color component, as I'm interested > only in greyscale images, and assume that antialiasing is equal for > all color components. > > I suspect that the antialiasing routine is written for speed, > producing a result that is visually acceptable. Is there a way that I > can increase the accuracy of the antialiasing routine? Or, do I have > to turn to more GPGPU/shader kind of solutions, when I'm more > interested in accuracy then in speed? > > I use Mesa in a VirtualBox, so I guess it's all software rendering. The mesa swrast AA triangle code is in src/mesa/swrast/s_aatriangle.c and s_aatritemp.h The compute_coverage() functions (different versions for RGB vs. CI mode) basically count how many subpixel samples lie inside the triangle for each pixel. A jittered 4x4 sample pattern is used. You could probably increase the number of samples to improve AA quality a little. Brian 