How would you setup render targets for portals?

I have a qeustion about how you would setup render targets for portals. Im currently trying to fix mahalis’s hpd and as you may know the portals wont allow you to see through them. So thats my objective; to fix the hpd portals. Ive already done some work on this regaurding the materials. Ive noticed that the vmts are coded wrong so i fixed them but it didnt do much. All that did was make it so you could see the “noblue” and “nored” textures without that balck boarder around them. But it didnt fix the main issue of the black boarder around the normal portals. So could anyone tell me how i might be able to fix this? I know it has something to do with a gmod update and a newer way of how to setup render targets. Is there an lua code that will fix this or could it be fixed by seting up the vmts differently? Im assuming it would require a mixture of lua coding and vmt coding along with some vtf masks or somthing.