   glsl: how to not write all gl_FragColor components
  Hi,I have a question regarding the behaviour of writing to a subset of all gl_FragColor components. When I run my glsl code doing something likegl_FragColor.xy = ...it will overwrite the z and w values with 0. But in some resources I sometimes read that the input texture is also used as the target texture into which is rendered because the inputchannels are different than the output channels. With the behaviour I get its not possible to resuse the texture in that way (without sampling the value of zw and writing it again).Now my question: is it supposed to work like this (meaning: it is not possible to write certain channels only and leave all others  as they are) or am I just missing something?From what I gather I think it is not possible because thats what the discard; command is for (otherwise we could just not write to gl_FragColor). Whats the oppinion of the glsl pros here?Thanks alot,David   
  You should not write to gl_FragColor anyway--it's been long deprecated.   ;Maybe glColorMask can work for you?I'm not sure if according to the spec it is legal to read/write to the same buffer, even if you use different channels, so this might be undefined behaviour. Worth a try though.   ;  Hey Thanks alot for your replies.@Prune: whats the proper way to do it? gl_FragData[]?@karwosts: glColorMask is a good hint ! Thanks! I think I might use it.The source I was refering to is the dof implementation of starcraft2. In their siggraph paper they say that they compute CoC in the alpha channel of a map and use the same map to store the blured rgb values of the source image. Either they somehow manage to prevent overwriting the alpha value or maybe they blur and compute in one shader together (which I dont like).However, I think I've enough to go on. Thanks and happy coding,David   