nanos-world / issues

Issue Tracker for nanos world
9 stars 1 forks source link

Render Targets #427

Closed Derpius closed 2 years ago

Derpius commented 3 years ago

Describe the solution you'd like

Expose UE's render target system in some capacity to allow drawing to textures from Lua in real time.

Describe alternatives you've considered

More "lower level" render lib functions, for drawing polygons manually with vertices (quick to implement, but can't support a RenderView implementation, and harder to use as you'd need to manually project and deproject over and over again to fake a texture in world space)

gtnardy commented 3 years ago

Hello there! Thank you for the issue!

Please let me know all your ideas to use that! Primarily I had the idea to expose this to allow drawing cameras outputs into textures and use as materials into objects. Depending on what are your ideas, we may think on some different approaches!

If you want to load custom textures, we have this ability already with :SetMaterialParameterTexture().

Derpius commented 3 years ago

Wiremod and StarfallEx (both addons that are used extensively in our community and to a lesser extent throughout all of gmod) have screens that can be rendered to in real time using a variety of methods using render targets.

The other main use-case is rendering a camera view to an RT (RenderView) and drawing that to a texture, which is used for everything from portals and minimaps, to sniper scopes and mirrors.

So a full implementation would need to support setting the resolution of the RT from Lua, drawing either pixel by pixel or using more abstracted render methods like gmod's, and drawing a camera view to one.

There's a few more niche things that we use RTs for in gmod, but implementation of the above, combined with being able to create a material from a WebUI panel, should handle 99% of everything anyone would ever want to do with them.

gtnardy commented 2 years ago

Hello there! Do you think we can consider this issue done? Or is there some point not yet covered?

Derpius commented 2 years ago

@gtnardy haven’t been able to keep up with all development progress recently (working on a rougelike and got a full time job), if something equivalent to the draw functions in https://wiki.facepunch.com/gmod/render has been added to paint to render targets then this is complete

Timmy-the-nobody commented 2 years ago

@gtnardy haven’t been able to keep up with all development progress recently (working on a rougelike and got a full time job), if something equivalent to the draw functions in https://wiki.facepunch.com/gmod/render has been added to paint to render targets then this is complete

Yes there's an equivalent to RT now -> https://docs.nanos.world/docs/scripting-reference/classes/scene-capture

Derpius commented 2 years ago

@Timmy-the-nobody that’s the equivalent of renderview only, being able to manually draw to a render target (using equivalents of gmod’s render.Draw* functions) is needed to reimplement things like wiremod’s digital screen and EGP, or starfall’s screen/HUD

Theoretically you could use Ultralight for this if canvas support were added, but being able to do it more directly without needing to run an entire webpage per RT would be far more efficient

gtnardy commented 2 years ago

This will be mostly added with the new Canvas class!