I found out what the problem was:
`RenderTexture.active = rndTxt;`
this will apparently clean up matrix information (amongst other things).
So, instead of:
GL.PushMatrix( );
GL.LoadOrtho( );
for( int i = 0 ; i < mat.passCount ; i++ )
{
mat.SetPass( i );
GL.Begin( GL.QUADS );
GL.Vertex3( 0.0f, 0.0f, 0.1f );
GL.Vertex3( 1.0f, 0.0f, 0.1f );
GL.Vertex3( 1.0f, 1.0f, 0.1f );
GL.Vertex3( 0.0f, 1.0f, 0.1f );
GL.End( );
}
you do
Graphics.DrawTexture(new Rect(-1.0f,-1.0f,2.0f,2.0f), some_texture);
that will render over the entire RT (the viewport's coordinates go from -1 to 1).
Also, bear in mind that DrawTexture expects pixel positions, so all parameters will be cast into ints internally. As a consequence, you can't give it things like
Graphics.DrawTexture(new Rect(-0.74984f,0.3494854.0f,0.16549f,0.23165f), some_texture);
as it all will be floored down to the nearest integer.
If like me you'd like to keep DrawTexture to use 'screen' coordinates (here, pixel positions) you'll have to rebuild a projection matrix yourself, something like that:
Matrix4x4 pm = Matrix4x4.identity;
pm[0, 0] = 2.0f / RT.width;
pm[1, 1] = -2.0f / RT.height;
pm[0, 3] = -1.0f;
pm[1, 3] = 1.0f;
and pass it on to the vertex shader and multiply your vertices positions with it. And then you can use pixel positions in the Rect you pass to DrawTexture instead of -1,-1,2,2 .