[feature] Render target saving to and loading from image
Closed this issue · 3 comments
Describe the solution you'd like
IRenderTarget:Load(filename)
which would load the contents of the file into the render target, resizing the RT as needed, and IRenderTarget:Save(filename, mip = 0)
which would save the contents of the render target at the specified mip to a file.
The file path would be relative to garrysmod/data/vistrace
and should sanitise out things like /../
(should be easy to do with the filesystem library).
Describe alternatives you've considered
Instead of scaling the RT to fit an image, it may be better to scale the image to fit the RT and add avistrace.LoadImage()
function to automatically size the RT.
This would allow loading images at a consistent resolution for post processing, or loading an image into a specific MIP level.
Added saving in 36d40c2
For some reason saving the image causes my gmod render target to go black (cause seems to be using the filesystem)
Seems like the issue is caused by rendering in the PostDrawHUD
hooks among others, HUDPaint
works fine so the issue is internal to GMod