The animation is not fluent at all and gives the feeling to get repeatedly freezed which is absolutly horrible for me as a user point of view.
So I did the same with open GL thinking the only way to get proper animations in Juce was to do the painting by yourself. Unfortunatly, running shaders into Juce gives you exactly the same result, with quick freezes which makes it totally unsuitable to do any kind of fluent animation movement. While in shadertoy.com or vertexshaderart.com this same shaders are running smoothly without effort.
A really wonder if itās only on my machine, if itās me who is doing something wrong, or itās just because those freezes are too subtile and people donāt care.
The fact is, for now, I didnāt find any way to just do one simple fluent animation in Juce.
Itās not something new, itās something I always experienced with Juce.
With my experience with OpenGL animation and Juce, while developinng my plug-in, UpStereo Pro : https://www.quikquak.com/ (I designed the display shader in Shadertoy, which was a lot of fun!)
You have to remember that itās a plug-in and you have a lot of competition for graphics. Youāre sharing the rendering with possibly over a dozen other things, all wanting the #1 slot!
Only have one OpenGL context, and calling the other renders when the main ārenderOpenGLā is called, not forgetting to set the viewport in each. This sped things up nicely for me with multiple panels.
I did this because Iāve had hang crashes in the swap buffers in Cubase and Logic when using multiple contexts. Especially recently.
If you still have slow-downs then set setContinuousRepainting to false, and openGLContext.setSwapInterval(0) using a timer to call repaint() at about 30 frames a second to stop getting in the way of the host rendering and other plug-ins etc. (Itās also a reasonable frame rate and a good compromise in most situations) - it reduced judder and felt a lot smoother when I tried this. You could try using 60 fps of course, but that depends on many things I donāt know about what you are rendering.
A another answer would be to use Metal and the latest DirectX, but thatās another storyā¦
*edit - I wasnāt aware of the AnimatedAppComponent. You could use that instead of using a timer like I suggested above, itās pretty much the same thing.
Thanks for the advice about having a single openGL instance.
Currently Iām looking at other alternatives like IPlug2 that claims to be 60 fps ready and embeds the Skia graphical backend from google, It runs fine on my side and I need to benchmark it to compare it with the Juce performances drawing, how the text renders, how the antialias performs, cpu perfs, etcā¦
Also I really like your plugins especially the pitch shifter one, glad to know UpStereo Pro animation has been done with a shader.
that is a really cool use of a shader in a plugin @DaveH, but you should have called it āeye of mordorā. Iām probably not the first to say that !
@olilarkin Hey thanks, yeah it means you only need 2 polygons, as the GPU can ray-march whole scenes in the fragment shader alone GPUs are insanely fast, even oneās on Apple machineās these days!
Hereās an āeye of mordorā I did seven years ago(!)ā¦ (it might be buggy on iOS as it only supports WebGL1)
With Juce the animation is not fluent at all and the square seems to have spasms while moving.
With Iplug2/skia cpu rendering, those animations are quite fluid and smooth, I noticed some rare cases when it jerked, but with Juce itās like 2 jerks per second, which is quite unsuitable.
It could be great if the juce team could look up at this issueā¦
TBH I made even more complicated animations that are running fluid.
So chances are you are doing something in your code that is not compatible with the way juce works or is buggy.
So without the code to replicate the issue it is probably impossible to comment.
Addition: Have a look at the DemoRunner: Browse demos -> GUI -> AnimationExample
I can reproduce the issue here with Juce 6, Visual Studio 2019 and Windows 7.
However, I wonder if the issue is because of using the getFrameCounter call to calculate the rectangle positionā¦One should probably instead use a clock time difference calculation for that.
edit : Unfortunately, an initial test without using the getFrameCounter didnāt solve the issue. It still looks like some frames are āskippedā. I need to test a bit more, in case I did some mistake with the alternative implementation.
I was looking at the source (am on mac). The getFrameCount() is incremented in the timerCallback().
This could only be different from the clock, if the Timer is set so fast that it cannot finish.
May I ask what timer interval you set?
I would be surprised if a value below 100 (actually 30 should be ideal) makes those problems, but I might be wrongā¦
I tested back the IPlug2 version and now I get those ājerksā issue on it too, where before it was quite 100% perfect.
Honnestly I donāt know too much if itās an issue of Juce or if itās related to the OS itself, or even the screen.
Thanks for the help anyway Iāll invest.
Maybe itās some issue with hardware interrupts or something? I suppose more people on Windows should test this, so we could start to understand this issue. (On my part, I can say it isnāt the classic āturn off your WIFIā-issue, because this desktop PC I am on at the moment, doesnāt have WIFI. )
When animating ideally you should never rely on the frame rate to do animations you should always calculate animations based on time otherwise it will behave differently on different machines. I can see the tutorial is using getFrameCounter(). I would suggest the tutorial is updated to prevent people making this mistake.
I already tested that alternative approach, like I explained above. It didnāt help. The issue is apparently something that prevents the component painting from working reliably. Itās probably something in Juceās Windows implementation that does something heavy in the GUI thread every 2 seconds or so, or a Windows system issue.
@xenakios oh sorry totally missed that. How odd! To be clear youāre using the time since the app or animation started to calculate a position? It doesnāt surprise me much if the odd frame is missed but I wouldnāt expect it to be noticeable.