Closed Derpius closed 2 years ago
Added loading in 8d7b72da388188f76224b8793f0cbc6ec6763fa4
Added saving in 36d40c243ba89b85365100daede04dce25212d97
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
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, andIRenderTarget: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 a
vistrace.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.