• GMod - What are you working on? September 2016 (#61)
    330 replies, posted
I dont bake it, more like render it. If anyone has an idea of how I can bake this (compute lighting and somehow fixtate it onto a model so I can move around in a static scene) it would be beyond amazing, but I doubt it'll ever be possible
[QUOTE=VIoxtar;51109747]I dont bake it, more like render it. If anyone has an idea of how I can bake this (compute lighting and somehow fixtate it onto a model so I can move around in a static scene) it would be beyond amazing, but I doubt it'll ever be possible[/QUOTE] iirc someone in the waywo managed to bake lightmaps to props (I'll take a look around) FOUND IT! [url]https://facepunch.com/showthread.php?t=1525274&p=50745434&viewfull=1#post50745434[/url] [video]https://youtu.be/aMXyKMcBWeI[/video]
Thanks - I feel overly optimistic, but I still sent him a PM asking if he's got an idea about it
weeeeeeee [video=youtube;RNBgQ5nyyUc]http://www.youtube.com/watch?v=RNBgQ5nyyUc[/video]
[QUOTE=Arizard;51116213]weeeeeeee[/QUOTE] I've seen something like this before. I don't remember what it is called.
[QUOTE=SatoshiAaron;51116230]I've seen something like this before. I don't remember what it is called.[/QUOTE] Rocket jumping in Team Fortress 2? :v:
I remember doing one of the firsts gmod beta workshop addons related rocket jump...ahh what beautiful time when i were an entusiast, happy and non money seeker ;( Good work! Looks really nice, i think you do a better air control (in the case you are not just adding a force upside)
[QUOTE=swadicalrag;51116343]Rocket jumping in Team Fortress 2? :v:[/QUOTE] well actually it was based on quake rather than tf2 but close enough
Who needs laser dance when you have [I]rocket[/I] dance
WOO I found a way to make blur with minimal performance impact, and has no weird artifacts around the edges when clipped. Any lag in this video is ShareX. [quote][vid]http://zombine.me/file/2016-09-27_13-49-17.mp4[/vid][/quote]
How do you do a blur without having to render scene again, that's why it has perfomance impact Althought, in HUD you can create lots of polys and then render a single pass with stencils in PostHUDPaint But what about 3d2d, i can't imagine how can you optimize that
[QUOTE=gonzalolog;51118129]How do you do a blur without having to render scene again, that's why it has perfomance impact Althought, in HUD you can create lots of polys and then render a single pass with stencils in PostHUDPaint But what about 3d2d, i can't imagine how can you optimize that[/QUOTE] I'm constantly calculating blur and rendering it to an RT inside a RenderScene hook. Then, in 3D2D, I draw a rectangle and use stencils to call render.SetMaterial(myRT) and do render.DrawScreenQuad(), clipping them to the 3d canvas. So unfortunately for every 3D2D screen, a quad is being drawn on the screen, but it's muuuuch less expensive than computing blur for each screen individually, since all my operations are done with surface.* functions, and not vgui panels. The downside is that there is a constant 10 FPS loss, but I'd rather take a constant 10 FPS hit once than 10 FPS per screen
Oh! That's pretty awesome! Then you just took the idea from 2d to apply it into 3d, really awesome
[QUOTE=Z0mb1n3;51118157]I'm constantly calculating blur and rendering it to an RT inside a RenderScene hook. Then, in 3D2D, I draw a rectangle and use stencils to call render.SetMaterial(myRT) and do render.DrawScreenQuad(), clipping them to the 3d canvas. So unfortunately for every 3D2D screen, a quad is being drawn on the screen, but it's muuuuch less expensive than computing blur for each screen individually, since all my operations are done with surface.* functions, and not vgui panels. The downside is that there is a constant 10 FPS loss, but I'd rather take a constant 10 FPS hit once than 10 FPS per screen[/QUOTE] Although this isn't a code snippet I feel like this should still go on that "Useful Code Snippets" thread.
[QUOTE=YourStalker;51118604]Although this isn't a code snippet I feel like this should still go on that "Useful Code Snippets" thread.[/QUOTE] after I figure out how to optimize it a bit more, I will. at present, though, it does call render.RenderView so if you use it in your code, you need to add in some conditions to tell it when not to calculate blur, otherwise you're taking an "ambient" FPS hit of about 40 FPS (for me at least). The reason I have to use renderview is because when using render.PushRenderTarget it clears the depth buffer, and I have to re-render the player's screen in order to capture the blur. If you know of a way around this, let me know! EDIT: i think I answered my own question, i'm gonna mess around with it EDIT 2: nope have to use RenderView i guess. still better than losing 10-20 fps per blurred object
I don't understand - why do you need to RenderView, and why do you need the depth buffer in another render target?
[QUOTE=NeatNit;51120187]I don't understand - why do you need to RenderView, and why do you need the depth buffer in another render target?[/QUOTE] Because I am calculating multiple passes of the pp/blurscreen shader, and rendering them to a material which I can use, rather than re-computing blur for each element. I have to use render.RenderView because when I push a new render target onto the stack, there is no data being rendered to the screen. If I simply use the blur materials and render them to the screen, the material is still black - therefore, I need to render the player's screen, draw and compound the blur, then export that to the render target. Once that is done, I can freely use the material wherever I wish without the need to recompute the material for each panel or vgui element.
[QUOTE=Z0mb1n3;51118157]I'm constantly calculating blur and rendering it to an RT inside a RenderScene hook. Then, in 3D2D, I draw a rectangle and use stencils to call render.SetMaterial(myRT) and do render.DrawScreenQuad(), clipping them to the 3d canvas. So unfortunately for every 3D2D screen, a quad is being drawn on the screen, but it's muuuuch less expensive than computing blur for each screen individually, since all my operations are done with surface.* functions, and not vgui panels. The downside is that there is a constant 10 FPS loss, but I'd rather take a constant 10 FPS hit once than 10 FPS per screen[/QUOTE] 10 fps loss? What's your original fps? That's kind of useless info by itself, after all losing 10 fps from 300 is not that bad, but losing 10 from 20 is very bad.
Okay. Consider this alternative approach: Wait until the whole scene is rendered and the depth buffer is still good - for example, PreDrawViewModel (I think). Then, copy the rendered screen over to your other render target and blur it there, then do all the 3D2Ds. Is there a reason why this wouldn't work?
[QUOTE=NeatNit;51120494]Okay. Consider this alternative approach: Wait until the whole scene is rendered and the depth buffer is still good - for example, PreDrawViewModel (I think). Then, copy the rendered screen over to your other render target and blur it there, then do all the 3D2Ds. Is there a reason why this wouldn't work?[/QUOTE] Blurring materials still takes quite a bit of grunt no matter which way you do it, and achieving a decent effect takes many passes of the shader
doesn't RenderView take more time though? (also I'm no longer sure that PreDrawViewModel is what I thought it was, but there's gotta be a hook somewhere)
[QUOTE=NeatNit;51120571]doesn't RenderView take more time though? (also I'm no longer sure that PreDrawViewModel is what I thought it was, but there's gotta be a hook somewhere)[/QUOTE] I think you misunderstand; I am using render.PushRenderTarget to render blur to a material. The reason I don't just use pp/blurscreen is because I have to re-blur the material [b]for every panel I draw blur on[/b] Any rendertarget is innately [b]black/empty[/b] if nothing has been drawn to it. It is a clear canvas, and I'm forced to render the player's screen a second time [b]inside[/b] the render target, so the data is there. Now, I apply the blur with multiple passes, capture the output, and store it in a new material. RenderView takes about 30-40 fps from me, which is the downside. I'm looking for ways to simply copy the contents of the current rendertarget (being the player's view) instead of rendering the screen again, then drawing the blur and capturing the output in another texture. render.CopyRenderTarget may be along the lines of what I want, so I'll experiment with it some more tomorrow
[QUOTE=swadicalrag;51116343]Rocket jumping in Team Fortress 2? :v:[/QUOTE] No it definitely isn't this. I don't play TF2
[QUOTE=Z0mb1n3;51120917]I think you misunderstand; I am using render.PushRenderTarget to render blur to a material. The reason I don't just use pp/blurscreen is because I have to re-blur the material [b]for every panel I draw blur on[/b] Any rendertarget is innately [b]black/empty[/b] if nothing has been drawn to it. It is a clear canvas, and I'm forced to render the player's screen a second time [b]inside[/b] the render target, so the data is there. Now, I apply the blur with multiple passes, capture the output, and store it in a new material. RenderView takes about 30-40 fps from me, which is the downside. I'm looking for ways to simply copy the contents of the current rendertarget (being the player's view) instead of rendering the screen again, then drawing the blur and capturing the output in another texture. render.CopyRenderTarget may be along the lines of what I want, so I'll experiment with it some more tomorrow[/QUOTE] Ah! I know this then! Once you've already rendered what you want via normal means: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/UpdateScreenEffectTexture]render.UpdateScreenEffectTexture[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/GetScreenEffectTexture]render.GetScreenEffectTexture[/url] If you want, copy it into your own RenderTarget using your favorite method, mine is Material("pp/copy") Then do whatever! The only tricky thing (and what I was trying to explain/circuvment) is knowing WHEN to pull the image from the rendered screen, i.e. when to run UpdateScreenEffectTexture. If you do it too early, you won't have the whole scene, for example just the skybox. If you do it too late, you'll have HUD or even the main menu / console window included. Good luck! [editline]28th September 2016[/editline] This is how to use Material("pp/copy") to copy from one texture to another: [url]https://github.com/garrynewman/garrysmod/blob/451b4ff5d1aea7b9b06a8024ef706c248a79647e/garrysmod/lua/includes/modules/halo.lua#L105-L108[/url] [lua]render.SetRenderTarget( target_texture ) mat_Copy:SetTexture( "$basetexture", source_texture ) render.SetMaterial( mat_Copy ) render.DrawScreenQuad()[/lua]
[QUOTE=Z0mb1n3;51120917]I think you misunderstand; I am using render.PushRenderTarget to render blur to a material. The reason I don't just use pp/blurscreen is because I have to re-blur the material [b]for every panel I draw blur on[/b] Any rendertarget is innately [b]black/empty[/b] if nothing has been drawn to it. It is a clear canvas, and I'm forced to render the player's screen a second time [b]inside[/b] the render target, so the data is there. Now, I apply the blur with multiple passes, capture the output, and store it in a new material. RenderView takes about 30-40 fps from me, which is the downside. I'm looking for ways to simply copy the contents of the current rendertarget (being the player's view) instead of rendering the screen again, then drawing the blur and capturing the output in another texture. render.CopyRenderTarget may be along the lines of what I want, so I'll experiment with it some more tomorrow[/QUOTE] When it was the goal to have a translucent rendertarget that you can draw over the original view (thus not having to render the renderview into the target) have fun: [code] render.PushRenderTarget( hud3d ); render.OverrideAlphaWriteEnable( true, true ) render.ClearDepth() render.Clear( 0, 0, 0, 0 ) // RENDER HERE render.OverrideAlphaWriteEnable( false ) render.PopRenderTarget() [/code]
[QUOTE=NeatNit;51120955]Ah! I know this then! Once you've already rendered what you want via normal means: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/UpdateScreenEffectTexture]render.UpdateScreenEffectTexture[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/GetScreenEffectTexture]render.GetScreenEffectTexture[/url] If you want, copy it into your own RenderTarget using your favorite method, mine is Material("pp/copy") Then do whatever! The only tricky thing (and what I was trying to explain/circuvment) is knowing WHEN to pull the image from the rendered screen, i.e. when to run UpdateScreenEffectTexture. If you do it too early, you won't have the whole scene, for example just the skybox. If you do it too late, you'll have HUD or even the main menu / console window included. Good luck! [editline]28th September 2016[/editline] This is how to use Material("pp/copy") to copy from one texture to another: [url]https://github.com/garrynewman/garrysmod/blob/451b4ff5d1aea7b9b06a8024ef706c248a79647e/garrysmod/lua/includes/modules/halo.lua#L105-L108[/url] [lua]render.SetRenderTarget( target_texture ) mat_Copy:SetTexture( "$basetexture", source_texture ) render.SetMaterial( mat_Copy ) render.DrawScreenQuad()[/lua][/QUOTE] I admit, I'm a bit lost. Here is my current code. Hopefully it will clarify things. Using a gist because facepunch keeps making me use a captcha for pasting lots of code, which annihilates my post... [url]https://gist.github.com/87f3db81d9609682b21e4a571c17ecc1[/url]
Just FYI, you used bit.band instead of bit.bor. Besides that, honestly, I'm a bit lost about what's going on myself. Specifically, how blur works. The pp/blurscreen material is defined as: [code]// Todo: Make own shader with widely variable blur (and no refraction!) "GMODScreenspace" { "$basetexture" "_rt_FullFrameFB" "$texturealpha" "0" "$vertexalpha" "0" } [/code] In laymen's terms, it uses the same generic GMODScreenspace shader that many of the other materials use, and has the Screen Effect Texture as a base texture. But does that base texture do anything? I have no idea what those other two do. :snip: okay, so I was in the middle of simultaneously testing stuff and writing this post... then it became really late and now I really have to go to bed... So I will try to finish this post tomorrow. My current thoughts are: are you sure this is the version that produced the video above? Because according to the tests I've ran, it makes no sense that that code works. I don't have the other half of your code so I can't test it directly. FWIW, the goal as I see it is to remove the need for RenderView altogether. I think this is completely doable. Edit: for clarification, when I "finish this post" it will be in a new post, so don't bother coming back to this one looking for a late edit ;)
[QUOTE=NeatNit;51123252]Just FYI, you used bit.band instead of bit.bor. Besides that, honestly, I'm a bit lost about what's going on myself. Specifically, how blur works. The pp/blurscreen material is defined as: [code]// Todo: Make own shader with widely variable blur (and no refraction!) "GMODScreenspace" { "$basetexture" "_rt_FullFrameFB" "$texturealpha" "0" "$vertexalpha" "0" } [/code] In laymen's terms, it uses the same generic GMODScreenspace shader that many of the other materials use, and has the Screen Effect Texture as a base texture. But does that base texture do anything? I have no idea what those other two do. :snip: okay, so I was in the middle of simultaneously testing stuff and writing this post... then it became really late and now I really have to go to bed... So I will try to finish this post tomorrow. My current thoughts are: are you sure this is the version that produced the video above? Because according to the tests I've ran, it makes no sense that that code works. I don't have the other half of your code so I can't test it directly. FWIW, the goal as I see it is to remove the need for RenderView altogether. I think this is completely doable. Edit: for clarification, when I "finish this post" it will be in a new post, so don't bother coming back to this one looking for a late edit ;)[/QUOTE] i'm gonna stop clogging up waywo with this after this post, so it's best you just PM me. the code I gave you is exactly what I'm using, which works fine. Without the RenderView call, I get a blank rendertarget. (technically, there is a blur layer being drawn, but blurred black is still black)
-snip- I understand why you are caching the blur. :speechless:
[QUOTE=Z0mb1n3;51123385]i'm gonna stop clogging up waywo with this after this post, so it's best you just PM me. the code I gave you is exactly what I'm using, which works fine. Without the RenderView call, I get a blank rendertarget. (technically, there is a blur layer being drawn, but blurred black is still black)[/QUOTE] At least post it in Code snippets when you got it fixed please. :pudge: Cuz some of us really want to know how you managed to get the blur with very low fps drop.
Sorry, you need to Log In to post a reply to this thread.