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.

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).

thanks. do you know what gl_texcoord[0].st means ?

.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… ?


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.

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