Radial blurring?

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Radial blurring?

Post by GyroVorbis »

I tried to find it at wikipedia and google with no luck (kept finding photoshop tutorials). Does anybody know the math/process behind radial blur? Are you just rendering a scene and distorting the framebuffer (almost like anti aliasing)?
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Post by GyroVorbis »

Maybe it has another name, or you don't know it by that term. Here's a screenshot of what some guy did (Dreamcast too).

Image
http://yam.20to4.net/dreamcast/index_old.html
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Post by GyroVorbis »

Okay, I got it for the most part. Just looked at some OpenGL tutorials. Does anybody know how I'd create a texture out of a scene (through framebuffer I think)?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

There used to be a way in KOS to do just that, but when the PVR code got rewritten around KOS 1.1.7 or 1.1.8, it was never rewritten.

When I get a bit of time, I'll see if I can get it working again, but the last time I tried I couldn't get it right.....
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Post by GyroVorbis »

Oh man, please let me know if you get anything accomplished. That would be much appreciated.
quarn
DC Developer
DC Developer
Posts: 80
Joined: Wed Oct 17, 2001 7:44 pm
Location: Sweden
Has thanked: 0
Been thanked: 1 time

Post by quarn »

There are several ways to do radial blur. For simplicity I am going to ignore pure "render to texture" stuff and go with the two ways that are similar to how I usually do it:


1:

a) render scene
b) copy frame buffer to texture
c) draw this texture to the scene with alpha < 1 and scale > 1
d) draw this texture to the scene with alpha less than previous step and scale more than previous step
e) repeat d several times until desired effect is reached

Good: Always gives the same blur effect no matter what your framerate is
Bad: lots of overdraw == expensive!


2:
a) render scene
b) render overlay texture with scale > 1 and alpha < 1
c) copy framebuffer to overlay texture
d) repeat

As you render more and more frames, the overlay texture gets more and more blurred. The bad part with this is that on a low framerate you get a "feedback" effect, but on a high framerate it looks very nice and is very cheap since you only draw one transparent overlay each frame.
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Post by GyroVorbis »

The only problem is that I don't know how to copy the framebuffer to a texture. According to Crabby, it sounds like you can't do that with the newer versions of KOS anymore.

How were you doing it?
quarn
DC Developer
DC Developer
Posts: 80
Joined: Wed Oct 17, 2001 7:44 pm
Location: Sweden
Has thanked: 0
Been thanked: 1 time

Post by quarn »

On dc I just rendered the same object several times a la version 1 as I described below. So you have:

a) render object
b) render object with alpha < 1 and scale > 1
c) render again with alpha less than previous step and scale > previous step
d) repeat c until satisfied

Expensive as hell because of all the overdraw/blending, but it works.
User avatar
Stef.D
DCEmu Respected
DCEmu Respected
Posts: 114
Joined: Wed Oct 15, 2003 1:46 am
Has thanked: 0
Been thanked: 0
Contact:

Post by Stef.D »

Looks really interesting :)
Can you do render to texture on dreamcast ?
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Post by GyroVorbis »

I'm pretty sure that you can--or as Crabby said at least used to be able to.

I am planning to work a lot tonight, I'm going to give that a try, thanks Quarn. I don't think it should be too expensive for me, I should be good.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Stef.D wrote:Looks really interesting :)
Can you do render to texture on dreamcast ?
Hopefully after the next few weeks, I'll have time to figure out how to fix that support.... Right now classwork at the university's kinda overwhelming me.
User avatar
Stef.D
DCEmu Respected
DCEmu Respected
Posts: 114
Joined: Wed Oct 15, 2003 1:46 am
Has thanked: 0
Been thanked: 0
Contact:

Post by Stef.D »

BlueCrab wrote:
Stef.D wrote:Looks really interesting :)
Can you do render to texture on dreamcast ?
Hopefully after the next few weeks, I'll have time to figure out how to fix that support.... Right now classwork at the university's kinda overwhelming me.
That would be really cool.
Render to texture open the door for many neat render effects.
I hope we can do it without trick (as render to FB and copy FB back to texture) :)
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Ok, I got a little bit of time to sit and hack around with render to texture support, and I'm happy to report that I got it working. I haven't had a chance to adequately test it yet (i.e. in the case that you're using DMA to do all the primitive transfers), but it does work with what KOS gives you in the default setup.

I'll probably commit what I've worked out to the KOS subversion repository either tonight or tomorrow (including a small example of how to use it).
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has thanked: 0
Been thanked: 0
Contact:

Post by JS Lemming »

Woot Woot!
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Well, upon further tests, I've found that what I have so far needs some work. I basically tried to do a radial blur effect using the texture, but it failed miserably. I know that I have gotten it set up properly (as I can dump the generated texture out to an image file, and it looks like it should), but because of the odd way I hooked it in the rendering code, it won't work in its current form for a radial blur effect....

I have an idea of how to fix it, which I will attempt to implement in the morning.
User avatar
Stef.D
DCEmu Respected
DCEmu Respected
Posts: 114
Joined: Wed Oct 15, 2003 1:46 am
Has thanked: 0
Been thanked: 0
Contact:

Post by Stef.D »

Nice to heard you got it working, great job man ;)
How did you basically do it ?
I mean, can you render to a texture in one pass ?
I guess we can probably render a scene to a squared sized frame buffer then use that frame buffer as a texture... something like that ?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Stef.D wrote:Nice to heard you got it working, great job man ;)
How did you basically do it ?
I mean, can you render to a texture in one pass ?
I guess we can probably render a scene to a squared sized frame buffer then use that frame buffer as a texture... something like that ?
Exactly how it works.... basically, when you want to do a render to a texture, instead of calling

Code: Select all

pvr_scene_begin();
you do something like this:

Code: Select all

pvr_scene_begin_txr(texture, &texture_width, &texture_height);
Right now, the texture_width and texture_height have to be 1024 and 512 respectively, but eventually, I'll get that problem fixed, so that they can be adjusted as necessary (and the function will adjust them on its own).

The only problem is, the way that the PVR code is set up in KOS, you have to draw do a few more frames before you can count on the texture being correct. As I said, I'm trying to figure out a good way to fix this problem, but I haven't gotten it quite yet.
User avatar
Stef.D
DCEmu Respected
DCEmu Respected
Posts: 114
Joined: Wed Oct 15, 2003 1:46 am
Has thanked: 0
Been thanked: 0
Contact:

Post by Stef.D »

BlueCrab wrote:
Stef.D wrote:Nice to heard you got it working, great job man ;)
How did you basically do it ?
I mean, can you render to a texture in one pass ?
I guess we can probably render a scene to a squared sized frame buffer then use that frame buffer as a texture... something like that ?
Exactly how it works.... basically, when you want to do a render to a texture, instead of calling

Code: Select all

pvr_scene_begin();
you do something like this:

Code: Select all

pvr_scene_begin_txr(texture, &texture_width, &texture_height);
Right now, the texture_width and texture_height have to be 1024 and 512 respectively, but eventually, I'll get that problem fixed, so that they can be adjusted as necessary (and the function will adjust them on its own).

The only problem is, the way that the PVR code is set up in KOS, you have to draw do a few more frames before you can count on the texture being correct. As I said, I'm trying to figure out a good way to fix this problem, but I haven't gotten it quite yet.
Does that pvr_scene_begin_txr is available in the KOS library ?
or you wrote it ?
Is the overhead very expensive for now ?
Keep us informed about your progress, it's something very interesting :)
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 81 times
Been thanked: 64 times
Contact:

Post by GyroVorbis »

Yeah, keep us updated, Crabby. Thanks for your work. :D

I'm pretty sure that no matter how expensive it is, it'll definately be a lot better than just rendering everything like 10 times...
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Ok, if you want to play around with rendering to a texture, I just committed the code. Also, there's an example of how to use it in http://svn.allusion.net/svn/kos/kos/exa ... ender/ta.c

Enjoy.
Post Reply