Derpius / VisTrace

Garry's Mod binary module for tracing meshes at high speed on the CPU (and much more)
https://derpius.github.io/VisTrace
MIT License
27 stars 1 forks source link

[feature] Render target saving to and loading from image #42

Closed Derpius closed 2 years ago

Derpius commented 2 years ago

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.

Derpius commented 2 years ago

Added loading in 8d7b72da388188f76224b8793f0cbc6ec6763fa4

Derpius commented 2 years ago

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)

Derpius commented 2 years ago

Seems like the issue is caused by rendering in the PostDrawHUD hooks among others, HUDPaint works fine so the issue is internal to GMod