Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

Pages: (6) 1 [2] 3 4 ... Last » ( Go to first unread post )
Gpu Shader Filter 0.5, weekend experiment
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
Loadus
Posted: Oct 13 2007, 12:21 PM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



QUOTE (phaeron @ Oct 13 2007, 02:56 AM)
Alright, quick lesson in pixel shaders ...

Fukken saved. Phaeron, you just won 3 internets.
This clears so much. Yeah, I had a notion on the blur effect, that large values
would be quite tricky. The classic bloom filter seems to do a framebuffer with
the texture sized half (or less), blurred and resized back (don't know if this is
the case, but visually it looks like it).

Holy monly. I'll start writing those and post them here when/if I get them working.
Thanks so muchos.

--------------------
deviantART behance
 
       Top
Loadus
Posted: Oct 13 2007, 03:50 PM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



Ok.
Here are the first contestants. Thanks again, Phaeron, for the rundown.

The full Hardlight effect:
http://www.loadusfx.net/virtualdub/hardlight_full.fx

Balanced Hardlight:
http://www.loadusfx.net/virtualdub/hardlight.fx

35mm film:
http://www.loadusfx.net/virtualdub/35mm.fx

35mm in use:

user posted image

user posted image

--------------------
deviantART behance
 
       Top
phaeron
Posted: Oct 13 2007, 05:25 PM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Sweeeet.

Resizing the frame buffer down and back up again doesn't work so well in practice, unfortunately. It sort of accomplishes a blur, but bilinear filtering isn't good enough to do the job, and you get weird diamond-shaped artifacts whenever there is motion.
 
    Top
Loadus
Posted: Oct 14 2007, 01:23 AM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



I got greedy with the calculations and copied settings directly from my
photo editor. So here's 35mm version II:

http://www.loadusfx.net/virtualdub/35mm_v2.fx


Version III gives a smoother output with opacity:

http://www.loadusfx.net/virtualdub/35mm_v3.fx


The code got kinda messy so I smacked a few comments in there to help
in adjusting the effect. The defaults are kinda rough, so don't be alarmed
if you blow your highlights out with this. Adjusting the contrast inside the
shader eases out the overall strength.

Here's version II in action:

user posted image



@Phaeron:
I was worried of rounding errors with this - that's why I asked about the
dithering - but in reality the result is ultrasmooth, you have to be a real
night-owl to see any artifacts other than what's resulted from original
compression. So yeah, skip that. biggrin.gif

I got the code for the 'Inversed Overlay' (it's actually more like 'contrast
mask' or 'tone mapping' but who cares) but it could really use a big radius
blur on it's 'gray layer'. Is there a 'hardware blur' in any of the new cards
buried somewhere in the system?

Anyway. I couldn't be happier, these fx files are real timesavers - I get
realtime HD processing (almost) with my card. I also shoved the same
shaders to Media Player Classic and yeah, you can watch DVD's or whatnot
with a real cinemafeel to them. Yay.

Oh yeah, is there a way to split the RGB into HSL and then combine them
back to RGB? I saw the code in the shader editor on YCbCr split and that
got me thinking ...

A color linearize filter would be to apply a 2.2 gamma to the colors only.
Split the image into two 'layers', apply 2.2 to the other one, then combine
only the H (and S) to the original. Hmmm ...

To be continued ...

--------------------
deviantART behance
 
       Top
phaeron
Posted: Oct 14 2007, 06:10 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



If you are using an NVIDIA graphics card, you might be able to speed up the shader slightly by replacing all instances of float, float2, float3, float4, etc. with half, half2, half3, and half4. This reduces precision from 32-bit float to 16-bit float, but 16-bit float is fine for most color computations.

I don't believe there is an easy way to do a hardware-assisted blur, even on the newer cards. You still have to do it manually. The blur and blur more samples will show you how to set up radius-1 and radius-2 blurs, but beyond that, it's just a PITA. Take a look at Warp Resize for some idea of what's involved in a multi-pass shader -- it does a gradient pass followed by a blur, and uses that to drive displacement mapping. I'd love to find some way to make this easier.

HSL and HSV are rather expensive color spaces to deal with, due to the cost of computing the position along the hue hexagon. YCbCr is faster to deal with, if your algorithm allows for it. There are two even faster color spaces which I sometimes use in shaders: one is [RGB-Y, Y], and the other is [RGB/L, L], where L=max(R, G, cool.gif. The first is good for very fast saturation changes:

CODE

const float3 lumacoeff = {0.30, 0.59, 0.11};
float4 px = tex2D(src, uv);
float y = dot(lumacoeff, px.rgb);

const float saturation = 1.2;
return (px - y)*saturation + y;


I've found that [RGB/L, L] or [RGB/Y, Y] gives nice results when dealing with brightness mapping, because it treats saturation better:

CODE

const float3 lumacoeff = {0.30, 0.59, 0.11};
const float factor = 0.4;

float4 px = tex2D(src, uv);
float y = dot(lumacoeff, px.rgb);
float adjust = pow(y, factor);

return px * adjust;


Incidentally, there's a nicer way to express a blend between two values: C*0.7 + B*0.3 == lerp(C, B, 0.3).
 
    Top
Loadus
Posted: Oct 14 2007, 01:54 PM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



Thanks for the help >again<. biggrin.gif

8800 GTX, there's room for more daring computation. wink.gif
Only thing slowing down the processing is the decoding the video, I threw H.264 .ts HD into Virtualdub through Avisynth and adding a GPU filter didn't show any slowdowns. Virtualdub gives the card frames in about 10-20fps (can't really say for sure).

Decoding is a lot faster with MPEG-2 HD, using fcchandler's ultramegasuperiormostneeded MPEG-2 input plugin.

But yeah, the best difference in processing compared to a regular filterchain is seen in applying those shaders to HD video. Most of the music video (+almost all the other) projects I'm involved with these days want the master to be done in HD. That's great but .. you give HD to After Effects and you can leave for a week - it's slow as hell. Doing all the mastering in Virtualdub is the only way to go from now on. biggrin.gif


EDIT:

Version 5 adds all kind of strange stuff into it, including a channel mixer. It defaults to +50% saturation so the colors can be kinda wild. Edit the values to 1.50 ---> 1.0 and -0.25 ---> 0.0 if you want to reset.

http://www.loadusfx.net/virtualdub/35mm_v5.fx


...

@Phaeron:

I just got my hands on a bloom filter script. Couldn't get it to work though, but it gave some insights to how that blur effect is done. And why it looks so blocky in some games. It's done with separate passes for H and V and the radius is controlled by doing those passes again. The calculations seem simple, though I have no idea how to get them to work in Virtualdub's shader - I tried to feed it vd_srctexture in both the original and the bloom 'layer', but it just passes it through - I'm probably missing some opacity variable or something.

My most ambitious shader was to implement a 'color space' shader for Virtualdub. I took CIE XYZ primaries and threw them to the card. I got it working but only after that I read that the "starting point" for the calculations has to be the sRGB weighting - and, well, I'm no mathematician so the formula just whacked me on the head - couldn't figure it out at all. And I couldn't get the m3x3 matrix to work either so manual * manual * manual. Yay. And there probably is a way to feed the card a real ICC profile and let it do all the work ...

We learn by doing.

--------------------
deviantART behance
 
       Top
arklight
Posted: Nov 29 2007, 09:35 PM


Advanced Member


Group: Members
Posts: 135
Member No.: 8316
Joined: 16-January 04



DAMMMMNN.

That's nice. Now if only i had a GPU that
supported this method....:-(

Booooo!

One thing i'd add though, the TECH guys at Lucasfilm
say that perceptully COLOUR is more important in PERCIEVED
resolution than line count and other technical resolution methods of
determining resolution to the lay man gawping at the screen.

Which makes sense because when you colour correct an image
even squashed down to internet trailer size if originated on film
it seems to take.

While your average SD or HD format in some cases needs some
carefully handling (or manhandling) to get good film like results.
Or just good colour corrected results.




Heri.
 
     Top
arklight
Posted: Nov 30 2007, 08:27 PM


Advanced Member


Group: Members
Posts: 135
Member No.: 8316
Joined: 16-January 04



Added some mo stuff to 300 thread since that's what started it off....

http://forums.virtualdub.org/index.php?act...t=0&#entry60766

lookee there at the end. Intreasted in your workflow even though
at the mo I can't access it...booo

heri
 
     Top
olnima
Posted: Dec 1 2007, 01:09 PM


Advanced Member


Group: Members
Posts: 204
Member No.: 17204
Joined: 12-November 05



QUOTE (blink @ Oct 8 2007, 07:39 AM)
It would be great to have an opportunity to change some parameters for certain video filters. For example, strength of Noise Reduction 2. By default it is too high...

Same request here. Instead of changing the parameters of the NoiseReduction2 it would be nice to have different nr2.fx-files with different fixed settings.
FYI: except noisereduction.fx every filter is working great with an ATI HD2600.

Thanks for your work

Olnima
 
     Top
phaeron
Posted: Dec 4 2007, 07:45 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Alright, got it working:
http://www.virtualdub.org/beta/gpufilter-0.6.zip

Example in .fx file:
CODE

float Displacement <
       bool vd_tunable = true;
       float vd_tunablemin = 0;
       float vd_tunablemax = -1.0f;
> = -0.2f;

 
    Top
arklight
Posted: Jan 19 2008, 02:11 PM


Advanced Member


Group: Members
Posts: 135
Member No.: 8316
Joined: 16-January 04



GPU FILTER FOR ABSOLUTE BEGINNERS


Thought I'd add this here as well because people might
hit this thread from nowhere from the net and be intrigued.


USED VIRTUALDUB BEFORE?

If you are one of those people and have NEVER used Virtualdub before
this thread should answer your questions:

http://forums.virtualdub.org/index.php?act...t=0#entry61780]

If you know what your'e doing let's get onto this great development...


WHAT IT DOES:

**REALTIME** FX AND ALTERING OF YOUR VIDEO OR IMAGES
VIA YOUR GRAPHICS CARD.



KNOWN PROBLEMS:

You might find you are missing a dll file.....

d3dx9_25.dll

you are told in the filter dialog
you can find missing DLLs here....

http://www.dll-files.com/dllindex/dll-file...shtml?d3dx9d_25

or search here...

http://www.google.co.uk/search?hl=en&q=mis...le+Search&meta=

download the dll and drop it into your
windows system32 folder.Any other problem, join
forum (free!) and just ask!

Some have seen the GPU filter downloaded
it and been baffled how to use it...so lets sort it out.



INSTALLING THE PLUGIN:


Basically you download and uzip the gpufilter and it's contents into the
virtualdub plugins folder.

It comes in two parts:

.1 The actual plugin, THE GPUFILTER VDF filter file.

.2 The .FX FILES which you browse for from the gpu filter dialog.
These are the specific FX that you apply. Like a BW.FX file might
turn images black and white


There is an animated gif below to show you again visually if unclear.
each step shown every couple of seconds..


user posted image


USING THE GPU FILTER:


.1 startup virtualdub by click on the exe or shortcut to the exe.

.2 Open your Video or image (file, open etc...)

.3 On the virtualdub interface click on video, then filters.

.4 Click on ADD in the filters stack dialog that comes up,

.5Search and select the GPU SHADER FILTER, the dialog should come up.

.6 THe GPU filter dialog,click browse to find the FX file.Select
which FX you want.

.7 This appears in the GPU filter dialog.Click preview
and to see the result.

.8 Click ok and you go back to filter stack.

.9 click ok again and you are back at the virtualdub video panes
the left pane being your original video/image and right being the
altered video/image

the above is probably better explained in the animated gif below...
each step displayed every couple of seconds

user posted image

FOR MORE INFORMATION....

Of course now the community will start to create more FX files
to rival the huge selection of virtualdub (.vdf) filters out there.
For more information about this particular filter contact AVERY LEE
and LOADUS
. You can do this by joining the forum (free!)
and sending them an email once logged in.Or posting a thread...



Heri
 
     Top
Loadus
Posted: Jan 23 2008, 05:32 PM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



@phaeron:

Is there a way to create noise in .fx shader? I looked at the noise(x) function,
but it doesn't like anything I feed to it? If I understood correctly, there is no
random(x) function in HLSL, right? That noise thingy is supposed to be it?

But how on earth is it thought to work?

--------------------
deviantART behance
 
       Top
phaeron
Posted: Jan 24 2008, 04:51 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



noise() doesn't work in any hardware shader. It only works with texture shaders, which are shaders run on the CPU to generate textures. The most straightforward way to use them is to have a texture shader put the noise into a texture and then read from the texture. Check the Warp Resize filter for an example -- it's triggered via annotations on the shader indicating the desired width, height, and function name for the texture. By default the texture uses the A8R8G8B8 format, so your outputs must be in 0-1. It's possible to switch this to A16B16G16R16F or A32B32G32R32F for better precision, although at a speed cost.

One of the things I've been meaning to do is to add support for loading a texture from disk, but there are oh so many things to do....
 
    Top
Loadus
Posted: Jan 25 2008, 12:30 AM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



Ah, that clears it - didn't understand why it didn't work. Aalrighty. Well, is there a way to capture the timer (from computer's clock) - like taking milliseconds and make them the random multiplier, like taking the .9751 from 08:39:23.9751? That would be quite random, right? Sorry for being such a n00b. biggrin.gif:D

--------------------
deviantART behance
 
       Top
phaeron
Posted: Jan 25 2008, 06:57 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



It probably won't be very random, but:
CODE

float4 vd_time;


vd_time.x will hold a value from 0-1 which repeats every 30 seconds.

Note that this value will be exactly the same for every vertex and pixel processed. If you need a per-pixel noise value, then you need to create a noise texture.
 
    Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
81 replies since Sep 16 2007, 08:06 AM Track this topic | Email this topic | Print this topic
Pages: (6) 1 [2] 3 4 ... Last »
<< Back to VirtualDub Filters and Filter Development