Jump to content
  • Advertisement
Sign in to follow this  
KumGame07

Shader basics

This topic is 4101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a damn basic question about shaders. Say I'm rendering a rectangle and I'm using vertex & pixel shaders. glBegin(GL_QUADS); .... glEnd(); My question is how many times the shaders will be exicuted ? I think Vertex shader will be exicuted 4 times (once for a vertex). But what about pixel shader ?

Share this post


Link to post
Share on other sites
Advertisement
It depends on how much space your quad represents on the screen (backbuffer). If you make your quad so large that it fills the entire screen the pixel shader will be executed once for each pixel.

Share this post


Link to post
Share on other sites
Correct me if I am wrong but AFAIK the pixel shader is executed once for each fragment, which does not necessarily equate to a pixel. In any case, this a small detail.

Share this post


Link to post
Share on other sites
Quote:
Original post by Morrandir
Correct me if I am wrong but AFAIK the pixel shader is executed once for each fragment, which does not necessarily equate to a pixel. In any case, this a small detail.


The only difference is when you perform FSAA, right? Otherwise, it's always one pixel, texel, fragment etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by rozz666
The only difference is when you perform FSAA, right? Otherwise, it's always one pixel, texel, fragment etc.


Yes, in most cases the number of fragments processed by the shader equals to the number of pixels.

Share this post


Link to post
Share on other sites
heh actually fragment shader is executed as many times as many fragments is being processed for a scene, so if you got lots of overdraw and its not handled by early-z rejecting then shader is executed many times for a single pixel of a screen(and this is why we are using pre-z pass and near to far drawing order). The curious question is what 'fragment' actually mean? ;)

Share this post


Link to post
Share on other sites
Last I heard a fragment was actually 4 pixels on the screen? Or the article I read was bad. Regardless, I think they meant it took the memory space for 4 pixels on the screen, or 16 bytes (RGBA*4).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!