Giter Club home page Giter Club logo

Comments (8)

PrimaryFeather avatar PrimaryFeather commented on June 2, 2024 1

When I apply a ColorMatrixFilter on and ImageLoader the image disapears. If I apply it on it's parent it works but has unexpected results (stuff gets moved around).

Did you try adding the filter only in the Event.COMPLETE event handler? Perhaps the filter gets drawn too soon, while there's no texture data available yet?

In any case, here is a simple utility function that allows you apply a filter directly to a texture.

from starling-framework.

PrimaryFeather avatar PrimaryFeather commented on June 2, 2024 1

I gave it a 2 seconds timeout where I can see the object rendered corectly, then it's drawn and replaced with the texture.

Hm, okay. Sorry for the troubles – this is absolutely something that should work. I hope I'll find the time to take another look at this problem.

For me it's a sort of cache where I reduce the number of objects from 35 (up to 80) to just 7. I've already generated a new texture, but the utility function could help too.

Okay! It's definitely a smart idea to use RenderTextures as a cache to simplify the scene. 👍

from starling-framework.

Adolio avatar Adolio commented on June 2, 2024

I just found a workaround and probably the root cause of this issue 😀

Apparently the transform of the root display object is not took into account when this later object is not added to the stage while drawing (but only for DisplayObjects with filters).

Workaround

addChild(_camera); // adding the drawn object to the stage solves the issue!
_renderingTexture.draw(_camera);
removeChild(_camera); // remove the drawn object to prevent rendering it twice

@PrimaryFeather Is this the intended behavior?

from starling-framework.

PrimaryFeather avatar PrimaryFeather commented on June 2, 2024

Haha, Aurélien, what are you doing to me? This is the worst possible combination to debug, filter plus render texture! 😂

I just tried to debug your sample to get to the root of the issue. It definitely has something to do with the object not being part of the stage, though I haven't been able to exactly put my finger on the problem.

When the current render target is a render texture, the fragment filter logic should replace all stage-related values with those of the render texture, as it effectively becomes the viewport in that case. I think I remember hitting a wall in that area, as my comment in this line shows.

In that case, the only solution would have been a breaking change in the DisplayObject class, which is a no-go, so I decided to postpone this change for Starling 3.0. 😉

To be honest, I'm not 100% sure it's exactly this issue. I'll try to look into it again with a clear head — getting my mind into this matrix stuff again is not easy. 🤪 But it seems very likely, and that your workaround fixes the problem indicates that it's connected.

At least you've got a workaround now!
The other thing you could do instead is to not use a render texture, but instead add a filter to your root object (whatever is "Starling.root") instead. In that case, every object can stay on the stage, and the FragmentFilter class can even optimize the filter bounds and not draw anything that's outside the stage.

However, if that's an alternative depends on what exactly you want to achieve.

from starling-framework.

MNiceback avatar MNiceback commented on June 2, 2024

from starling-framework.

PrimaryFeather avatar PrimaryFeather commented on June 2, 2024

from starling-framework.

Adrian-S avatar Adrian-S commented on June 2, 2024

I'm having the same issue, or similar.

When I apply a ColorMatrixFilter on and ImageLoader the image disapears. If I apply it on it's parent it works but has unexpected results (stuff gets moved around).

All gets drawn to a RenderTexture, and workaround did not work for me.

I will probably need to create multiple color textures for this. Is there a way to apply a filter to a texture and get a new texture out of it?

from starling-framework.

Adrian-S avatar Adrian-S commented on June 2, 2024

I gave it a 2 seconds timeout where I can see the object rendered corectly, then it's drawn and replaced with the texture.

For me it's a sort of cache where I reduce the number of objects from 35 (up to 80) to just 7. I've allready generated a new texture, but the utility function could help too.

Thank you.

from starling-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.