- March 15, 2017 at 3:48 pm #55417
Has anyone tried using an RGBA texture as both and output and input. I realise this is not advised but I wonder if it would be possible to use the R channel as the output while reading from the B channels. Technically it is feedback but I would have thought it could be possible if they were on separate color channels, using a glcolor mask to ensure B channel is not written to ?
Thanks for any infoMarch 17, 2017 at 2:19 pm #55418
As far as I am aware reading & writing to the same texture (FBO attachment) could result in undefined behavior (may return garbage data); to prevent this the attachment should only be a data source or target not both at the same time. I would recommend using two textures, i.e. fill the first texture with some data then set it as an input to the next stage in your pipeline and use the second texture as an output. If you only require one channel you can set the texture format to R8 which will give you a texture with a single 8 bit channel.
ShaunApril 13, 2017 at 12:35 pm #55606
Thanks for the reply Shaun,
Just leaving this as a note here – I did manage to get this working in the end, of course as I said at the outset, this is not a recommended approach. In our case we were very careful to ensure both reading (texture2d) and writing was not done to the same color channel.
RegardsApril 13, 2017 at 12:41 pm #55607
I am glad to hear you got this working, one thing to keep in mind though is that different devices may handle this situation differently so it may work on one platform but not on another, the behavior is dependent on the implementation provided by the graphics driver.