2D Filter runs per scene now (Blender 2.5)

Hi there,
for those out there testing Blender 2.5 daily there is a recent commit that changes the way 2DFilters work for multiple scene files.

In 2.49 all the 2DFilters were running together once per scene. That was producing two issues:

(1) Performance - To run the filters 2X == 2X slower
(2) flexibility of use - Very often we want the filter in the 3D scene but not in the UI for example.

For those reasons I believe that 2DFilters with multiple scenes were very useless or unpredictable. Now each scene can have its own set of 2DFilter. Keep in mind that the 2DFilter of an overlayed scene will still run on top of the main scene + its 2DFilter.

To make it work as before (2.4) you can simply recreate the 2dfilter actuators across the scenes.


Still didn’t get it?


Imagine that we have:
(a) Main Scene
(b) Overlay Scene

in Main Scene the Z Buffer and RGB will be from the main scene.
in Overlay Scene the Z Buffer will be from the Overlay Scene and the RBG buffer is from both [(a + 2D Filter) + b].

So in pseudo code if we have a,b,c,d,e scenes we have: (2DFilterE(2DFilterD(2DFilterC(2DFilterB(2DFilterA(a) + b) + c) + d) + e)

Very good!

thank god!

Thanks Dalai!

Here is a simple demo showing this new feature.
Blur is a 3 pass filter (1 -low quality blur, 2- image downsample, 3 -another low quality blur) resulting a fast and nice blur.

screenshot:
http://img641.imageshack.us/img641/9921/bluron.jpg

blend. http://www.pasteall.org/blend/2063
(note: you`ll need recent build of 2.5 from graphicall.org)

nice addition to the GE.

really great !

it could be useful if the filter of the overlay scenes could only apply to themselves and not to the underlying scenes. as an option.

I mean instead of what dfelinto explained (to my understanding…) :

scenes=[background,main,overlay]
for scene in scenes :
 frame add scene as overlay
 frame apply filter

render frame

one could have :


scenes=[background,main,overlay]
for scene in scenes :
 scene apply filter

for scene in scenes :
 frame add scene as overlay

render frame

what do you think ?

That would mean a lot of re-work and design changes. Not likely an “easy fix” (I wouldn’t even consider this as a fix myself, since it’s simply a different approach).

Thanks martinsh for putting this demo together. It illustrates well the problem/solution.
Cheers

Can it be done so we can exclude objects in the same scene the 2D filter is applied to? Say you want to apply a Sobel edge detection filter and you want to exclude the main character for instance, how much code would that take?

(I just realized that I never replied to that).
2D Filters run per screen. The only way that I know to isolate the effect for one object is from a fragment shader running in the object you pass individual data all the way to the 2D Filter (e.g. if you set the Z (Depth) in the fragment shader and use it in the 2D Filter to mask this object out.