Pages: [1]
  Print  
Author Topic: GLSL: Velocity based motion blur, downsampling, and max resolution  (Read 24675 times)
uunx
Nub


Cakes 0
Posts: 3


« on: July 17, 2014, 09:04:38 PM »

I've been developing a game / mod based on OpenArena (engine and qvms) and would like to improve my GLSL shaders as well as add some new stuff:

1. I'd like to implement velocity based motion blur - just based on camera movement for now not all vertexes. There's a handful of GLSL tutorials for motionblur that uses the vertex position & the change in camera position to fake blurs. However, they all require an input of the 'old' modelviewmatrix. I was wondering at what stage I should be saving the modelviewmatrix, in order to communicate it with the shader in the next frame? Any tips would be helpful.

2. I'm also having trouble downsampling the GLSL shaders. I've taken a look at how the bloom works (to my understanding) but can't replicate it for the GLSL shader. What I'd like to do is shrink the screen, apply my shader, resize it & set it to 'add'. I can do all of these steps, but for some reason when resizing the shader it still displays as if it was calculated using all pixels - no framerate improvement either. The shader is "blur" based so a lower resolution would be ideal. It seems like the r_bloom_sample_size variable is used in the original postprocess function, yet it seems to make no difference.

3. The game crashes (for me) using GLSL shaders on a resolution higher than about 1680*. I'm not sure of the exact resolution but it definitely doesn't work on 1920* res. I figured this could be due to running into the max texture size while rendering to the postproc effect texture. Is this an engine limitation, and would the downsampling I mentioned above avoid this issue?


Thanks for any input / tips on any of the above 3 issues.

Logged
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« Reply #1 on: July 17, 2014, 09:30:39 PM »

1. I'd like to implement velocity based motion blur - just based on camera movement for now not all vertexes. There's a handful of GLSL tutorials for motionblur that uses the vertex position & the change in camera position to fake blurs. However, they all require an input of the 'old' modelviewmatrix. I was wondering at what stage I should be saving the modelviewmatrix, in order to communicate it with the shader in the next frame? Any tips would be helpful.

I actually did try to implement velocity motion blur but didn't get far.  The camera matrixes seems fixed, and cgame would need to be modified to accompany this motion blur by sending delta vectors over to the renderer.   All that's left of this in the engine now are various GLSL variables unused.   Instead I did some simple effect that just blends 5 frames together but unfortunately it's only effective for 120+/240fps. and the method does look similar to Voodoo5's T-Buffer method in that one Q3 hack

2. I'm also having trouble downsampling the GLSL shaders. I've taken a look at how the bloom works (to my understanding) but can't replicate it for the GLSL shader. What I'd like to do is shrink the screen, apply my shader, resize it & set it to 'add'. I can do all of these steps, but for some reason when resizing the shader it still displays as if it was calculated using all pixels - no framerate improvement either. The shader is "blur" based so a lower resolution would be ideal. It seems like the r_bloom_sample_size variable is used in the original postprocess function, yet it seems to make no difference.

The bloom effect is rather old and fixed function.  If you do motion blur with the low resolution you'd have a noticable 'halo' effect around sharper edges, as well as more visible mipmap flickering.

3. The game crashes (for me) using GLSL shaders on a resolution higher than about 1680*. I'm not sure of the exact resolution but it definitely doesn't work on 1920* res. I figured this could be due to running into the max texture size while rendering to the postproc effect texture. Is this an engine limitation, and would the downsampling I mentioned above avoid this issue?

This was due to a typo in the caching of the depth texture.  This is fixed in the Git repository.
« Last Edit: July 17, 2014, 09:36:04 PM by fromhell » Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
uunx
Nub


Cakes 0
Posts: 3


« Reply #2 on: July 17, 2014, 10:36:12 PM »

Thanks for the quick response!

Quote
I actually did try to implement velocity motion blur but didn't get far.  The camera matrixes seems fixed, and cgame would need to be modified to accompany this motion blur by sending delta vectors over to the renderer.   All that's left of this in the engine now are various GLSL variables unused.   Instead I did some simple effect that just blends 5 frames together but unfortunately it's only effective for 120+/240fps. and the method does look similar to Voodoo5's T-Buffer method in that one Q3 hack

I was going to try to implement it based on a tutorial such as this: http://john-chapman-graphics.blogspot.co.uk/2013/01/what-is-motion-blur-motion-pictures-are.html which seemed simple enough. I thought the renderer would be able to save and reuse the modelviewmatrix without needing to change the cgame? Or is the game the only thing that can handle / track 'frame' timing or something? I don't yet have a full understanding of the engine/cgame roles.

I haven't taken a look at the frame blending method yet. Sounds interesting. I've seen similar with accumulation buffers but without oversampling frames (cool effect but mostly just looked like ghosting). I think if you could force when the frames are rendered, that method would work great. EG. rather than the oversampled frames being equally spread out, grouping them into tiny time differences. That would probably make it work for varied FPS too. I think Q3MME used to do something similar, HLAE definitely did (capture tool for goldsrc halflife / CS).


Quote
The bloom effect is rather old and fixed function.  If you do motion blur with the low resolution you'd have a noticable 'halo' effect around sharper edges, as well as more visible mipmap flickering.

This is for a separate shader I'm attempting. Its not quite "bloom", but its blur based. I checked to make sure it would work by upscaling it in photoshop and applying it over the original screenshot before attempting it with code. I couldn't seem to figure out at what point it should be downscaled and upscaled. Everything I did just left the shader the same once it was back up to full size.




Logged
Hitchhiker
Member


Cakes 11
Posts: 181


« Reply #3 on: August 20, 2014, 11:35:33 AM »

hi,

not sure if you're still trying to do things with the engine or if you already managed to get it working but, for what is worth (I'm by far no expert on this subject).. I'm actually trying to do rotation blur and for this would need the ModelView[projection?]Matrix, etc.. What I am doing is capturing the matrices stored in glState variable (inside the function that draws the sky), storing them (as they will change over different scenes in one video frame of a gameplay) and send that to the glsl postprocessing - without this the ModelViewMatrix at postprocessing time is a simple Identity matrix (I think) so not really useful.

Hope this helps. If you have a question I could help maybe with, please feel free to ask.

as for my rotation blur effect.. am struggling at the moment but will eventually get there for sure (I'm not sure if my matrix is correct or if it is the screenresolution or even the glsl program that's giving the incorrect effect).

Cheers
Logged
uunx
Nub


Cakes 0
Posts: 3


« Reply #4 on: August 21, 2014, 02:34:40 PM »

Since posting, I've changed the engine I'm using (switched to UE4 which has the type of blur I was after). But thanks anyway.
Logged
Pages: [1]
  Print  
 
Jump to: