I have a problem with mapping of texture in fragment shader. I have a texture that has same size as window (I use part of scene rendered in previous pass, but I use brick texture in the example below) and I need to map it as in 2D. Is it somehow possible ? I tried different ways, but nothing worked.
Could you please advice me how should the fragment shader looks like ? Please any advice will be helpfull. Thank you!

So if I understand you correctly, then you want to use the previously generated texture as if it was some kind of “layer”, where texture pixels map 1:1 to viewport pixels, and the texture has the very same size like the viewport?
If so then this is very easy (as of GLSL version 1.30). There is the function
texelFetch, which takes a pixel index as coordinate (unliketexturewhich takes a value in the range [0; 1]). The built in variablegl_FragCoordgives the window coordinates of the currently processed fragment. So by using the coordinates ingl_FragCoordfortexelFetchyou get the desired result.