David M
David M

Reputation: 53

WebGL fragshader ... what is the incoming value of gl_FragColor?

I'm learning to write fragment shaders, but as I'm playing with blending modes, I'm confused about incoming values of gl_FragColor.

When main() is called in the frag shader, before it's modified within main(), what is the value of gl_FragColor? Is it always vec4(0.0, 0.0, 0.0, 1.0)? Is it the value of of previous passes at that same pixel? Is it something else? How is the value determined?

Upvotes: 0

Views: 353

Answers (1)

derhass
derhass

Reputation: 45342

gl_FragColor is an output value, not an input one. The GLSL 1.0 ES spec states:

Reading from these variables before writing to them results in an undefined value

So you can't rely on it being set to antything particular at all.

Upvotes: 4

Related Questions