• Render targets
    7 replies, posted
Could anyone give me a small explanation on how to use them properly? I [URL="http://facepunch.com/showthread.php?t=1002403&p=24883910&viewfull=1#post24883910"]found[/URL] [URL="http://facepunch.com/showthread.php?t=1216661&p=37946359&viewfull=1#post37946359"]many[/URL] [URL="http://facepunch.com/showthread.php?t=1023894"]helpful[/URL] threads but all of them are pretty outdated and don't answer my only question. Last thread kinda does answer it, but I don't think I can mount settings/render_targets from an addon file, can I? Besides that people kept saying garry will re-added making render targets from lua, which till now I couldn't find any documentation on. In each one of them there is a missing bit, GetRenderTarget always uses a string/var which is defined nowhere. I have no idea what it is referring to, either. I understand you get the render target then do stuff on it, then actually draw the render, but how do I set what and where to draw on? Let's say I have a weapon model laying on the ground, what would be the best way to take that weapon model and draw it on the HUD let's say or even better in 3D2D? And would I need to create more RTs for each weapon on the ground or can I use the one created over and over as long as I clear it?
[QUOTE=arcaneex;42933631] Let's say I have a weapon model laying on the ground, what would be the best way to take that weapon model and draw it on the HUD let's say or even better in 3D2D? [/QUOTE] Use DModelPanel ( All it does is render the ClientsideModel on a panel )
I tried making my own version of it (turning it around, stopping animation, coloring it depending on small if conditions ) which worked great, minus the fact that I couldn't get it to render in 3D2D. It would always pop up on the HUD. A small bird told me to use SetPaintedManually but I didn't get to try it out just yet because last time when I tried to remove the panel it failed and error'd. (code below) [lua] -- ... random code, x is equal to a weapon on the ground local mpanel if LocalPlayer():GetEyeTrace().Entity == x then mpanel = vgui.Create( 'custom DModelPanel/Regular DModelPanel' ) mpanel:SetModel(x:GetModel()) else if mpanel then mpanel:Remove() end end [/lua] With both original and custom model panel it failed to close it, removing the if mpanel will just error. Either way, I'll have to learn how to use render sooner or later.
Make sure you're not calling vgui.Create in a HUDPaint or similar function, or you're going to get a ton of panels created and have a bad time.
Yeah I'm aware of that, thanks for the tip though.
[QUOTE=arcaneex;42935151]I tried making my own version of it (turning it around, stopping animation, coloring it depending on small if conditions ) which worked great, minus the fact that I couldn't get it to render in 3D2D. It would always pop up on the HUD. A small bird told me to use SetPaintedManually but I didn't get to try it out just yet because last time when I tried to remove the panel it failed and error'd. (code below) [lua] -- ... random code, x is equal to a weapon on the ground local mpanel if LocalPlayer():GetEyeTrace().Entity == x then mpanel = vgui.Create( 'custom DModelPanel/Regular DModelPanel' ) mpanel:SetModel(x:GetModel()) else if mpanel then mpanel:Remove() end end [/lua] With both original and custom model panel it failed to close it, removing the if mpanel will just error. Either way, I'll have to learn how to use render sooner or later.[/QUOTE] I am not sure if you are able to actually draw it in 3D2D at all, but it should be possible. You gotta call the rendering function inside your 3D2D camera ( Just copy it from DModelPanel ), make sure to do CLMDL:SetNoDraw( true ) do disable default rendering. Do not use DModelPanel or other panels, you gotta do the whole thing from scratch.
Found a workaround, not perfect but suffices. Fonts ftw. [t]http://cloud-4.steampowered.com/ugc/723121698744096098/CF51F2820DA9935A6D58B4125BA6C4D83B2AC44E/[/t] I'd still like to learn to use renders, though.
[QUOTE=arcaneex;42936421]I'd still like to learn to use renders, though.[/QUOTE] I always find it helps to read source when you can't figure out how to use something properly: [URL="https://github.com/garrynewman/garrysmod/blob/ff51a59d5a821dec3c8f524631c86150b3e4744d/garrysmod/lua/vgui/dmodelpanel.lua"]https://github.com/garrynewman/garrysmod/blob/ff51a59d5a821dec3c8f524631c86150b3e4744d/garrysmod/lua/vgui/dmodelpanel.lua[/URL]
Sorry, you need to Log In to post a reply to this thread.