Mutsuyuki  Tanaka
Mutsuyuki Tanaka

Reputation: 135

Is fragment shader run at out of screen?

I use webgl 1.0.

I want to know that if I set vertices out of -1 ~ 1 range, fragment shader run at out of screen(also framebuffer) or not.

[example]
If I set like below.
draw type : gl.LINES
vertices : [-100000,-100000, 100000, 100000] <--- 1 line made by 2 point

I think display result is same when I set
vertices : [-1,-1, 1, 1]
(Both result are show 1 straight line from left bottom to right top.)

I want to know first example is slower performance caused by lot of running fragment shader.

Upvotes: 5

Views: 627

Answers (1)

Rabbid76
Rabbid76

Reputation: 210909

No, only the fragments which are in the view volume are processed by the fragment shader. The other fragments are clipped.

The Primitives are clipped in the Vertex post-processing stage.

The Clipping rule is applied on the clip space coordinates (gl_Position):

-.w <= .x, .y, .z <= .w

Fragment processing is done later after the Rasterization.
See also Rendering Pipeline Overview

Upvotes: 4

Related Questions