Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


#ActualMilcho

Posted 24 January 2013 - 09:39 AM

Shaders only run for what's on screen, due to how the graphical pipeline fills pixels (or fragments, as they're called, there's a small difference)

The shader optimization extends further, so to minimize what pixels need to be filled. In general:
a) Be on screen - what you're concerned about
b) Pass the depth test - this means that if you draw some object above ground first, and then draw the ground, the pixels of the ground that are hidden by the object will not be shaded (not rendered by shader). Note that if you draw ground first, and then the object, all the ground's pixels will be filled. In other words, if making huge optimizations, it pays off to draw nearby objects first, before drawing further away objects (or ground).
c) Pass the stencil test - unrelated to your question, but its yet another thing that is used to optimize which pixels get filled.

Edit: To add to that explanation, when you specify a triangle, there is no notion of a 'pixel' on the triangle.
Triangles are transformed into screen space, and those that lie partially outside the screen have their shape re-adjusted, as to 'clip' them. This means that no pixels that are off-screen will be rendered at all, which is what I meant by a) above.
After that they are rasterized into fragments/pixels and each fragment is subject to the two other tests (b and c above).

#1Milcho

Posted 24 January 2013 - 09:32 AM

Shaders only run for what's on screen, due to how the graphical pipeline fills pixels.

 

The shader optimization extends further, so to minimize what pixels need to be filled. In general:

a) Be on screen - what you're concerned about

b) Pass the depth test - this means that if you draw some object above ground first, and then draw the ground, the pixels of the ground that are hidden by the object will not be shaded (not rendered by shader). Note that if you draw ground first, and then the object, all the ground's pixels will be filled. In other words, if making huge optimizations, it pays off to draw nearby objects first, before drawing further away objects (or ground). 

c) Pass the stencil test -  unrelated to your question, but its yet another thing that is used to optimize which pixels get filled.


PARTNERS