Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Difference between vertex and fragment shader ?

  1. #1
    Intern Newbie
    Join Date
    Apr 2012
    Posts
    45

    Difference between vertex and fragment shader ?

    Why can't I do everything with fragment shader only or vertex shader ? What are they actually ?

    and what is a "varying" variable.

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    Vertex shader transforms the vertices before the rasterization, the fragment shader is responsible for the coloring per fragment. Varying (in/out) is a way to send information from the VS to the FS. You should look up the rendering pipeline to understand the basic concepts (e.g. "Real-Time Rendering" by Akanine Möller is a good recource).

  3. #3
    Intern Newbie
    Join Date
    Apr 2012
    Posts
    45
    thanks. do you know what gl_texcoord[0].st means ?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,580
    .st is convention for .xy for texture coordinates.

  5. #5
    Intern Newbie
    Join Date
    Apr 2012
    Posts
    45
    Quote Originally Posted by ZbuffeR View Post
    .st is convention for .xy for texture coordinates.
    these positions are related to texture ? are they used for picking pixels (something like getpixel(x,y)) ? and why st or xy, i have always used uv for textures.. ?

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,580
    RTFM
    http://www.opengl.org/wiki/GLSL_Types#Vectors
    Additionally, there are 3 sets of swizzle masks. You can use xyzw, rgba (for colors), or stpq (for texture coordinates). These three sets have no actual difference; they're just syntactic sugar. You cannot combine names from different sets in a single swizzle operation. So ".xrs" is not a valid swizzle mask.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •