Talk:Adding Motion Blur

From Valve Developer Community
Revision as of 15:20, 29 June 2008 by Amckern (talk | contribs) (I reject the speedy deletion)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


view_scene.cpp \cl_dll\view_scene.cpp(1934) : error C2664: 'IMaterialVar::SetTextureValue' : cannot convert parameter 1 from 'IMaterial *' to 'ITexture *'

       Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

\cl_dll\view_scene.cpp(1939) : error C2065: 'pMatMBlur' : undeclared identifier :(

With the fixes that were added, it should be working now. Make sure to get the latest code from here and try again. --Snakez

What am I doing wrong here?

I've followed the tutorial to the letter, but my poor C++ skills are letting me down, it seems :-(

Build errors: src\cl_dll\view_scene.cpp(71): error C2039: 'DoMotionBlur' : is not a member of 'CViewRender'

src\cl_dll\view_scene.cpp(73): error C2065: 'pp_motionblur' : undeclared identifier

src\cl_dll\view_scene.cpp(73): error C2228: left of '.GetInt' must have class/struct/union type type is unknown-type

.. and so and so forth.

Anyone know what i've done wrong? --JamesHarrison 05:59, 23 Aug 2005 (PDT)

I updated the tutorial.. add

 #include "materialsystem/materialsystemutil.h"

--Garry Newman 11:55, 6 Nov 2005 (PST)

Bug? Or Just some sort of glitch?

Every thing works good, great tutorial! However there is some kinda weird thing going on. all the breakable crates and just the breakable crates are doing a HOM effect instead of having their textures drawn. Has anyone else come across this? I did the tutorial exactly as it was presented so I'm not sure why it's doing this.


How would one go about doing a precace on this texture, seeing that it is not a real metrial?

I have done a PrecacheMaterial( "HUDoverlays/frontbuffer" ); but MB is still laging on the first load...

  • Possibly because of this?: pMatScreen = materials->FindMaterial( "frontbuffer", TEXTURE_GROUP_OTHER, true );ts2do (Talk | @) 20:52, 11 Nov 2005 (PST)
    • that wont matter becuase my code has been changed to reflect the movement of the frontbuffer material

It isn't hitching when loading the material, it's hitching when creating the texture for some reason. Call the GetMoBlurTex0() function before it starts the game to create the texture there instead of in-game. --Garry Newman 03:28, 21 Nov 2005 (PST)

Velocity Sensitive Motion Blur?

How can this motion blur code be adjusted in accordance with the velocity of the player? In other words, how can the ferocity of the blur be increased or decreased when the player is accelerating or decelerating? --Adam Webb 09:55, 21 Dec 2005 (PST)

Bloom tutorial?

I'd love to see a similar tutorial on how you implemented bloom Garry :)

I thought I read somewhere that Gmod's bloom was with shaders.. Well, it's impossible with only code... Oke, I know this isn't helping, just a note... -- dutchmega

What about if I change map?

Dunno if anyone still reads this but anyway... I noticed some problems with the motion blur code when swapping levels. The blur won't behave very well untill the new map has been running for as long time as the last one. Wouldn't something like

if( (fNextDrawTime+pp_motionblur_time.GetFloat()*2) > gpGlobals->curtime )
fNextDrawTime = gpGlobals->curtime + pp_motionblur_time.GetFloat();

right after

if( gpGlobals->curtime >= fNextDrawTime ){...} 


void CViewRender::DoMotionBlur( void )

be kind of smart to put in?

--Lorre 17:19, 28 Jan 2006 (PST)

  • This was fixed in an edit i made - it loads the blur as soon as the level is ran, and not starting from when the last levels finshed. - the edit was from code at chatbear --Amckern 19:57, 28 Jan 2006 (PST)

Motion Blur only Occur when pixels reach certain velocity

How would one go about to have the motion blur only draw/blur pixels that move at a certain speed value. In real life, motion blur only occurs when an object reaches a certain speed due to the human brain's reaction time.

This type of motion blur I'm talking about can be found in Next Gen Gaming.

Does anyone know which values I should edit and add in order to achieve this effect? --Brad Newsom 22:29, 19 Apr 2006 (PDT)

You should detect velocity ...if velocity is past a certain value, do the blur. you should also track eyeangle changes & find a delta & test it—ts2do 22:33, 19 Apr 2006 (PDT)

It looks like garry has recently added this feature to gmod10, hopefully he can pop in here and give yu some pointers ^Ben 06:29, 20 Apr 2006 (PDT)

If he doesn't pop in here, I'll see what one of the coders can do with it, and if it achieves the effect of next gen graphics, then I will make it public. :) It all depends if Garry wants to be generous. hehe --Brad Newsom 10:57, 20 Apr 2006 (PDT)

Once the shader update is out, I'm thinking of havin a bash at making a proper shader to perform motion blur, although I can't promise much. Alot of the rendering stuff has changed in the last update, so god only knows if/when I'll be able to figure it out. Wraiyth 08:40, 12 Aug 2006 (PDT)

Re: August Update

UpdateScreenEffectTexture may not work, I had to change several of my shaders before they would work properly. Amckern did make a fix to the page, but if anyone gets a compile error on that line, then you should do the following:

Declare the DoMotionBlur() function with int x, int y, int width, int height

In RenderView(), pass the function view.x, view.y, view.width and view.height

In DoMotionBlur(), use UpdateScreenEffectTexture( pMaterial, x, y, width, height)

I'd make an edit but I'm not entirely sure on the UpdateScreenEffectTexture stuff and I'm not on my main computer. Just a note in case anyone does get stuck on it. Wraiyth 06:49, 13 Aug 2006 (PDT)

I reject the speedy deletion

This way works with older versions than DX9, and I think having a choice doesn't hurt.

I second the motion -- this code was instrumental in showing me how to do a lot of other things with Valve's render system -- file it under general rendering tutorials! --Steve Henderson 19:19, 20 May 2008 (PDT)
I also reject the speedy deletion on this article. --Amckern 15:20, 29 Jun 2008 (PDT)