OpenGL line rasterization with integer endpoints -


in opengl specification, line rasterization defined 'diamond-exit' rule.

for each fragment f center @ window coordinates xf , yf, define diamond-shaped region intersection of 4 half planes:

rf = {(x, y) | |x−xf| + |y−yf| < 1/2}.

essentially, line segment starting @ pa , ending @ pb produces fragments f segment intersects rf, except if pb contained in rf.

(from opengl 1.5 specification, section 3.4.1)

this means line parallel x or y axis integer endpoints not drawn @ all. e.g. line starting @ (x,y) = (5, 5) , ending @ (5,10) never have manhattan distance smaller 1/2 fragment center.

is there reason why spec left such "hole" between 2 fragments?

in following part additional criterion described determine if fragment drawn:

to avoid difficulties when endpoint lies on boundary of rf (in principle) perturb supplied endpoints tiny amount. let pa , pb have window coordinates (xa, ya) , (xb, yb), respectively. obtain perturbed endpoints p′a given (xa, ya) − (ϵ, ϵ2) , p′b given (xb, yb) − (ϵ, ϵ2). rasterizing line segment starting @ pa , ending @ pb produces fragments f segment starting @ p′a , ending on p′b intersects rf, except if p′b contained in rf. ϵ chosen small rasterizing line segment produces same fragments when δ substituted ϵ 0 < δ ≤ ϵ.

(from opengl 1.5 specification, section 3.4.1)

i assume have added rule account edge cases example. why didn't allow points distance of 1/2 in first place?

also, since δ , ϵ positive, mean lines pass in middle between 2 fragment centers default lower fragment (with horizontal line) or leftmost fragment (with vertical line)?

but why didn't allow points distance of 1/2 in first place?

because result in generating 2 fragments in these cases, resulting in thicker line intended. 1 needs kind of tie-breaking rule, , formulation chosen in gl spec that.

also, since δ , ϵ positive, mean lines pass in middle between 2 fragment centers default lower fragment (with horizontal line) or leftmost fragment (with vertical line)?

no. because gl spec doesn't require implementations use diamond exit rule. paragraph quoted begins with

ideally, gl uses “diamond-exit" rule determine fragments produced rasterizing line segment. [...]

in later paragraphs stated:

because initial , final conditions of diamond-exit rule may difficult implement, other line segment rasterization algorithms allowed, subject following rules:

  1. the coordinates of fragment produced algorithm may not deviate more 1 unit in either x or y window coordinates corresponding fragment produced diamond-exit rule.
  2. the total number of fragments produced algorithm may differ produced diamond-exit rule no more one.

[...]

rule 1 alone allows implementation use tie-breaking rule of it's own choosing.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -