Canvas Resize – Some Update?

Hello,



interessting. The weired memory trash disappeared. Now the bloom filter and the cartoon filter “work” but only the rendered parts are drawn. The original spatials are freezed in the background. The real background is not updated anymore. If I draw a simple sphere with LightingMaterial it is drawn. Then I add a BloomFilter and the GlowSphere appears and can be moved. But I only see the “glowing sphere”. The original sphere stays in background.



You were once talking about a flag which should be set or not be set. Something with “clear …”.



@oOMoeOo

Can you please verifiy that BloomFilter works in your swing environment?



Thanks.



Regards,

Equi

Hello,



OK, now it works at least to 99%. Following happens. First I thought that the spatial is normally drawn with its LightingMaterial and the BloomFilter is only an “aura effect” letting the spatial glow on its border. Now I realized that the whole spatial is drawn as bloom object. If I add a FilterPostProcessor to my viewPort and then a BloomFilter to it following happens (in swing environment)…



1.) Add FilterPostProcessor…OK

2.) Add BloomFilter…Memory Mess is shown on the screen. White spots everywhere but a white glow effect is already visible. Indeed sometimes I can really see Bitmap text displayed, the figures and letters from your default font.

3.) Resize the Canvas by changing the JInternalFrame dimension (my canvas is added to a JInternalFrame).

4.) Now the Memory Mess has vanished…OK

5.) Now there can happen many things. In 99% I can rotate my scene and the glow effect works fine. I can change the glow color and everything is nice. Sometimes, the LAST frame which has been rendered BEFORE the bloomEffect started is still in background memory. If I resize the canvas again, it vanishes and bloomEffect works perfectly. There must be a line in the source code, where the background memory cache has to be deleted right AFTER or BEFORE the BloomFilter is activated. I think than it should work.



However, from where does the bitmap text come from :slight_smile:

I am looking for it…



Thanks for bloom filter…



Regards,

Equi

to disable a filter you remove it from the processor right?

When doing this it’s not cleaned, meaning that the texture and the framebuffer attached to it will still be bond to memory.

maybe that’s the issue…



I added a filter.cleanup call to the remove method, it safe because if you re add the same filter to the processor the FB will be recreated.

I also cleaned up every frame buffer created when you remove the processor itself from the view port

Maybe it will fix your issue

Hello,



you are absolutely right. To disable a filter or a SceneProcessor I remove it from the SceneProcessor or ViewPort respectively. Now I assume that there must also be a cleanup procedure AFTER I have added a sceneProcessor to the viewport and/or AFTER I have added a filter to the sceneProcessor. There are such methods. Should I call any of them immidiateley after I performed an add?



Thanks,



Regards,

Equi

No, it’s called internally, there is a filter.init when you add it and now there is filter.cleanup when you remove it.

Hello again,



@Equi, i can verify that the bloom filter worked all the time, but i had a problem similar to yours. If i add initially add a FilterPostProcessor without having any Filter attached and then i dynamically add a Filter during the update process the real scene will be freezed and only the filtered scene can be moved, rotated and so on. If the user tries to add a filter the filterpostprocessor will be removed from the viewport, the filter added to it and then the processor will be added again. That was the only workaround which made my implementation working.



@nehon thank you again for SSAO and the cleanup-procedure. But could you add an !initialized-check before performing cleanup on the FilterPostProcessor?



[java]Exception in thread “LWJGL Renderer Thread” java.lang.NullPointerException

at com.jme3.post.FilterPostProcessor.cleanup(FilterPostProcessor.java:207)

at com.jme3.renderer.ViewPort.removeProcessor(ViewPort.java:75)…[/java]



Edit: Tested and found out, that using the following lines at Viewport should fix it:



[java]public void removeProcessor(SceneProcessor processor){

processors.remove(processor);

if (processor.isInitialized()) {

processor.cleanup();

}

}[/java]



Well, without these line adding filters during the update process won’t work:

[java]@Override

public boolean update(CityApplication pCityApp) {

if (attachRequested) {

attach(pCityApp, null);

attachRequested = false;

update = true;

} else if (detachRequested) {

detach(pCityApp, null);

detachRequested = false;

update = true;

}

boolean ret = update;

update = false;

return ret;

}[/java]



[java]@Override

public void attach(final CityApplication pCityApp, final Node pParent) {

checkForProcessorCreation(pCityApp);

ViewPort vp = pCityApp.getMainViewPort();

vp.removeProcessor(processor);

processor.addFilter(getFilter());

setFilterCount(getFilterCount() + 1);

vp.addProcessor(processor);

}[/java]



[java]@Override

public void detach(final CityApplication pCityApp, final Node pParent) {

ViewPort vp = pCityApp.getMainViewPort();

vp.removeProcessor(processor);

processor.removeFilter(getFilter());

setFilterCount(getFilterCount() - 1);

if (getFilterCount() > 0) {

vp.addProcessor(processor);

}

}[/java]



Regard

Moe

OK…I thought a while ago of putting a enabled flag on filters, and i think i’m gonna do it now. That will avoid all this mess.



You guys will just have to add all the filters to the scene and disable or enable them to your convenience.

This make much more sense than adding and removing them, because the order in which you add filters is important.

For example SSAO needs to be first in the filter stack. Bloom and lightScattering should be at the end.

@nehon you just made my day :slight_smile:

Sorry for the double post but could someone fix the cursor update problem?



Try to set the resizable flag to true in the TestCanvas in test.awt and enter the canvas from outside the frame slowly inside it. Then the resizable cursor won’t be resetted to the default cursor. Or has it something to do with using the awt invokations? Would like to share a screen but taking screen shots will hide the mouse :wink:



Regards

Moe

Yhea i noticed it too, it’s not really my domain of expertise…but i’ll have a look. Can’t promise anything on that though.

ok check commit r6370

http://code.google.com/p/jmonkeyengine/source/detail?r=6370



you can disable and enable filters via the FilterPostProcessor (It needs to keep tracks on what’s enable and what is not)

like this



fpp.setFilterEnabled(filter,false);

1 Like

yeap. Works perfect, as expected. Thank you…

Hi,



while we’re on it, will there be a possibility to receive mouse double click events on the canvas using a swing environment?

Hey thanks for handle this. Works perfectly. But the SSAO filter shows some strange behavior - especially combined with the basic shadow renderer. Well i’ll test it a little bit. It seems that attaching the filterpostprocessor during the update calls will lead on to a freezing canvas. I’ll try to build a test case for you if i can manage it.



Regards

Moe

Well, i think i found out what about the problem with the ssao. Try the following test case in jme3.test.post.TestMultipleFilters. The lines can be found in the simpleInitApp(). Try only adding the ssao filter, but settings the min samples before.



[java]

fpp = new FilterPostProcessor(assetManager);

// set the min samples at least greater than 0 (2, 4, 8, 16)

fpp.setNumSamples(4);

ssaoFilter = new SSAOFilter(0.92f, 2.2f, 0.46f, 0.2f);

final WaterFilter water=new WaterFilter(rootNode,new Vector3f(-0.4790551f, -0.39247334f, -0.7851566f));

water.setWaterHeight(-6);

SSAOUI ui=new SSAOUI(inputManager,ssaoFilter);

final BloomFilter bloom = new BloomFilter();

final ColorOverlayFilter overlay = new ColorOverlayFilter(ColorRGBA.LightGray);



// only add the ssao filter

fpp.addFilter(ssaoFilter);

[/java]



It seems to be a problem with the aliasing settings, because if i set it to 0 it works trouble-free.



Moe

@oOMoeOo this is a known issue, filters that use depth (ssao, water, cartoon edge, lightscattering) cannot use multi-sampled FBO, because Depth buffer cannot be multi sampled prior opengl 3.0.



For now this is not possible, I thought i didn’t create the numSample setter though to avoid that…I’m wrong apparently.



Anyway I fixed the ssao resize issue, now every filter should resize properly. It’s in last SVN.

Well, ok … strangely it worked before. I had the filter post processors num samples set to 8 all the time and the scene looked far better than without using it. You’re right, the resizing now works perfectly and without setting the num samples the use of the filterpostprocessor and the enable and disable process works perfectly too :wink: Will there be a chance to use a higher sampling rate anytime?

Are you sure it was with SSAO? it works with bloom, for example, but not ssao.



For multisampe, we’ll look into it eventually, but i’m afraid it will be available only for opengl 3.0.

Yes i’m completely sure. SSAO was the main reason for switching to jme3. And the first time i only used this filter with 8x multi sampling. See the following pictures. They were made with setting up the num samples before:









Regards Moe


Saw that the RawInputListener got two more methods. Have some classes implementing the RawInputListener interface. Currently both the methods are called all the time as fast as possible. Is this a desired feature? Was happy all the time, that using the RawInputListener doesn't lead on to much input calls.


any update on this?