Screen aligned quad

hi

i have an quad model and i try to write image based effects. but i have an little problem in the my vertex shaders.

how can i fit this quad to screen? ( my model is screenalignedquad in the rendermonkey)

sorry for my bad english

use a vertexshader like this:


void main(void){
   gl_Position =  gl_Vertex * 2.0 - 1.0;
   gl_TexCoord[0]  = gl_Vertex;
   }

and draw a quad like that (or replace it by a model):


glBegin(GL_QUADS);
  glVertex(1,1);
  glVertex(1,0);
  glVertex(0,0);
  glVertex(0,1);
glEnd();

thanks a lot.

from [-1,1], both x and y on screen, before write gl_Position

It has been suggested that rendering a screen aligned grid (sweet size to be determined per shader) as opposed to a single quad/triangle can be a good thing for performance. Haven’t tried it myself…

Doesn’t the grid mainly help in cases with shader divergence?

But definitely do a triangle which overlaps the screen instead of a quad!

some info on grids wrt GPGPU

http://www.graphicshardware.org/previous/www_2007/presentations/nickolls-tesla-gh07.pdf

and for the post processing domain there’s a presentation from gamefest08 lurking about on shader optimization strategies in a similar vein.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.