Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How often will a vertex shader be called?

Just to clarify while learning this stuff:

If I have a scene with just one rectangle declared like this:

const Vertex Vertices[] = {
    {{1, -1, -7}, {1, 0, 0, 1}}, // X Y Z, R G B A
    {{1, 1, -7}, {0, 1, 0, 1}},
    {{-1, 1, -7}, {0, 0, 1, 1}},
    {{-1, -1, -7}, {0, 0, 0, 1}}
};

How often will the vertex shader be called to render one frame? I believe 4 times.

But there is some interpolation going on with varying variables in the vertex shader. The fragment shader gets called a lot more often (usually for each pixel once). Is this correct?

like image 941
SecretService - not really Avatar asked Nov 24 '25 23:11

SecretService - not really


1 Answers

The vertex shader is called for each vertex in the primitive. The fragment shader is called for each fragment, in practice, this usually means for each pixel.

like image 145
Dr. Snoopy Avatar answered Nov 28 '25 16:11

Dr. Snoopy