Ignoring coding patterns and code clarity/quality:
This is a question I just don't know if it's inherently bad or inconsequential. I can't find enough on the inner workings of assigning to say: gl_FragColor in WebGL 1.0 or to an out variable in WebGL 2 (layout(location = 0) out vec4 color).
Is there some inherent additional performance cost for doing something like:
void main() {
gl_FragColor = vec4(0., 0., 0., 1.);
vec4 val = gl_FragColor * something;
...
gl_FragColor = val;
}
Or is it better to work entirely with interim declared variables and then assign to the out value a single time?
void main() {
vec4 thing = vec4(0., 0., 0., 1.);
vec4 val = thing * something;
...
gl_FragColor = val;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…