No, if you discard
then no buffers will be updated, regardless of whether you assigned to the output variable beforehand or not.
The discard
keyword is only allowed within fragment shaders. It can be used within a fragment shader to abandon the operation on the current fragment. This keyword causes the fragment to be discarded and no updates to any buffers will occur.
– The OpenGL ES Shading Language Specification, Page 58 (Page 64 in the PDF)
(emphasis mine)
If blending is enabled, then you could write a transparent color to the output that you want to "discard".
// discard;
out = vec4(0.0, 0.0, 0.0, 0.0);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…