|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Dynamic effects on a materialHi,
Im adding blurr to a material like this: fx = new EffectLayer(); viewport.addRenderLayer(fx); fx.addEffect(new LayerEffect(new BlurFilter(100, 0, 2))); material1.renderLayer = fx; This works with no problem. The material1 gets blurred nice and good. Then onEnterFrame I would like to update this blurr with new values something like this: function updateEffects(object,blurAmount):void { fx = null; fx = new EffectLayer(); fx.addEffect(new LayerEffect(new BlurFilter(blurAmount, blurAmount, 2))); object.renderLayer = fx; } function onEnterFrame( e:Event ):void { updateEffects(material1,100,) renderer.renderScene( scene, camera, viewport ); } But no matter what I do in the uppdateEffects-function I don't get it to work. As soon as I call updateEffects there are no blurr at all on the material. How can I update the blurr-filter dynamicly? Any help is very appreciated! /Gibbah |
|
|
Re: Dynamic effects on a materialI guess it is not possible to update a effect when it allready set?
I've seen other DOF blurr-examples when they make several materials with different blurr-amount and then the object switch it's material between those. That works great if you have one object that is duplicated. But if you have many different objects I think it would be better to do what Im trying to do, updating the current effect on one material rather then changing the material to another. Or am I wrong? |
|
|
Re: Dynamic effects on a materialOh, I just found out how to do it.
I used removeAllEffects() before I added a new effect ![]() In other words, delete the old effect first and then set a new. |
|
|
|
|
|
Re: Dynamic effects on a materialHi,
Maybe because you're executing updateEffects on your onEnterFrame loop no ? :) In fact you see just the blur filter 100,100,2
|
|
|
Re: Dynamic effects on a materialIm not sure how you mean. Im calling the updateEffects from my onEnterFrame loop yes, but that is what I want it to do. The effect should update constantly onEnterFrame. In my code example I first set the effect to blur 100,0. Then I wanted it to update to 100,100 by calling the updateEffects(material1,100) just to see a change if it worked. But it didn't. I just didn't get any blur att all (0,0) when I called the updateEffects function. But now when I use removeAllEffects() first in the updateEffects function it works. And now when it works I change the blurAmount dynamicly when I call the updateEffects function from the onEnterFrame loop. |
|
|
removeChildByName????????????? |
|
|
Re: removeChildByName????????????? |
|
|
Re: removeChildByName????????????? |
| Free embeddable forum powered by Nabble | Forum Help |