All Questions

Community

A
bServe Anonymous

Confused about fragment and pixels

Hello. May i know if my understanding about fragment is correct. Fragment is considered as pixel at here, and TEXTURE_PIXEL_SIZE is also a one fragment size. Besides, what determines TEXTURE_PIXEL_SIZE ?

  • Nathan Lovato replied
    Solution

    A fragment isn't a pixel.

    When the openGL backend rasterizes a triangle, that is to say, draws pixels on the screen, it can produce multiple fragments for one pixel, depending on the sampling settings.

    For a given pixel on the screen, if you're using anti-aliasing, the renderer may need to blend multiple fragments together, or to produce multiple fragments that map to the same pixel on the screen, e.g. because multiple triangles meet in that location.

    A fragment is in the sense "fragment of a triangle".

    TEXTURE_PIXEL_SIZE is the fraction of the viewport the size of one pixel represents. So it's not the fragment size exactly. A fragment may represent a thin geometric bit at the tip of a triangle.

    Note it's a really low-level consideration and in my experience that difference between fragments and pixels doesn't really affect the thought process when designing a shader. I personally think at a higher level of abstraction when working on shaders.

    I hope this helps. Let us know if you have more questions.