JPH, Ville - help with user bitmaps Import help for a script

Discuss the ZGameEditor Visualizer plugin for FL-Studio.

Moderator: Moderators

User avatar
Kjell
Posts: 1648
Joined: Sat Feb 23, 2008 11:15 pm

Postby Kjell » Tue Jan 17, 2012 12:06 pm

Hi guys,

Attached is a simple example of which the Bitmap can be swapped out in FL Studio.

As a sidenote, not a big fan of how this is currently handled in FL Studio though. Would have preferred that Bitmap properties could be defined in a similar fashion as the current float-based rotary knobs. That way you could also prevent people from messing up your preset with random bitmaps :roll:

K
Attachments
Grid.zgeproj
(24.94 KiB) Downloaded 201 times

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Tue Jan 17, 2012 4:12 pm

Thanks Kjell - that is pretty cool. One thing that surprised me is how much of a difference using the display list made too.

with display list = 58.8 FPS
without = 29 FPS

I'm definitely going to start using display lists myself.

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Tue Jan 17, 2012 9:57 pm

Here is with RGB depth - so this can be made in to the PixelParticle preset.


performance improvement is unbelievable -

CPU version runs ~ 6 FPS
GPUversion 58.8 FPS
Attachments
grid_RGB_Depth.zgeproj
(25.06 KiB) Downloaded 202 times
Grid_RGB_Depth.jpg
Grid_RGB_Depth.jpg (69.82 KiB) Viewed 4030 times

User avatar
Kjell
Posts: 1648
Joined: Sat Feb 23, 2008 11:15 pm

Postby Kjell » Tue Jan 17, 2012 10:14 pm

Hmm,

The 58.8fps is suspiciously close to 60fps .. big chance the application / your video card driver is simply capping the framerate, in which case it could go way beyond that. I'm getting over 1300fps on my system ( no, that's not a typo ).

Did you set FrameRateStyle to free? And what refresh rate is your monitor set to?

K

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Tue Jan 17, 2012 10:51 pm

I'm getting over 1300fps on my system ( no, that's not a typo ).


Thats amazing -

probably is capped , not set to free - using the frame rate monitor on the visualizer in FL Studio.

Edit : monitor refresh rate is 60.

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Wed Jan 18, 2012 2:16 am

Important to note - video export fails (just black screen) when you use an openGL display list - A performance hit without it - but still very fast. Not sure what is going on there - but I has to replace the call list with the code block to get my video export to render.


Anyway - this worked very well with a 30 FPS video texture too:

http://www.youtube.com/watch?v=54B2X4waRB8

alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Postby alphanimal » Wed Jan 18, 2012 7:53 am

That is awesome guys

Can't look into it now (I'm kinda busy during the week) but will asap.

You think it's possible to implement my physics code into that and it's gona run a quadrillion times faster?

User avatar
VilleK
Site Admin
Posts: 1920
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Wed Jan 18, 2012 12:37 pm

Hi, looks like you guys are making some progress here :)

I'll have to follow this from a distance at the moment because I'm very busy but regarding the display lists failing on export it is because the OpenGL context needs to be recreated when there is a new surface such as video export or window/detached and this leaves the display lists that was created invalid.

The ZGE render components deal with this automatically and recreate their OpenGL-state when needed but when scripts call OpenGL functions directly we need another solution. I'll probably just change it so that OnLoaded is called again when surface is recreated. I'll make a note of that for now.

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Wed Jan 18, 2012 3:30 pm

You think it's possible to implement my physics code into that and it's gona run a quadrillion times faster?


Yes - I'm sure of it - and way beyond. Kjell did an excellent job on the basic shader for this.

You should be able to figure it out from there - I can't wrap my head around your physics code. I'm looking forward to seeing a GPU version of your preset.

To put it in perspective:

Currently,

your preset 64x64 with lots of arrays and calculations is running at ~ 6 FPS on the CPU

Here processing

256x256 image
capped out > 60 FPS, but still not as demanding as your script

Pushing the envelope - 16x the size of the array you were using goes beyond you performance needs. This can't even run on the CPU.

1024x1024 capped out > 60 FPS


HD Video 30 FPS --> to 256x256 x 30 images/sec

Is still going at 40-50 fps

User avatar
Kjell
Posts: 1648
Joined: Sat Feb 23, 2008 11:15 pm

Postby Kjell » Wed Jan 18, 2012 4:18 pm

Hi guys,

StevenM wrote:Kjell did an excellent job on the basic shader for this. You should be able to figure it out from there.

That's probably a little optimistic :roll: Since ZGE doesn't support floating-point buffers ( it actually does internally for the GPU Array, but it's not exposed anywhere in the Editor ) you need to pull some ( fixed-point ) tricks to get the data around.

StevenM wrote:Pushing the envelope - 16x the size of the array you were using goes beyond you performance needs.

You can't really compare it like that though .. look-ups are a entirely different beast.

StevenM wrote:HD Video 30 FPS --> to 256x256 x 30 images/sec is still going at 40-50 fps

In that case the video decoder probably accounts for 99% of the CPU usage .. doesn't have much to do with the preset itself :wink:

K

alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Postby alphanimal » Wed Jan 18, 2012 5:01 pm

Kjell wrote:Hi guys,

StevenM wrote:Kjell did an excellent job on the basic shader for this. You should be able to figure it out from there.

That's probably a little optimistic :roll: Since ZGE doesn't support floating-point buffers ( it actually does internally for the GPU Array, but it's not exposed anywhere in the Editor ) you need to pull some ( fixed-point ) tricks to get the data around.
K


For my preset to work I need to store currently 14 float variables per vertex.
I used the 3rd array dimension for that.
I'd need to read each pixel's color independent of the vertex xy position too.

fixed point is OK I think as the variables have a very limited range (positions, colors, velocities, angles ...)

Could you help me out here? I'm completely lost when it comes to the shader code.

What's the VertexShaderSource and FragmentShaderSource about?

alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Postby alphanimal » Wed Jan 18, 2012 5:05 pm

Also I'd need to access FL's data from the shader (Parameters, BandSpecArray and AudioArray)

I guess that's done through the UniformVariables node?

Also I need some functions to calculate stuff: atan2, sqrt, floor, clamp
Are these available in shader code?

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Wed Jan 18, 2012 5:07 pm

You can't really compare it like that though .. look-ups are a entirely different beast.


That is what I was comparing though, current method opposed to the use of the shader - am going under the assumption that using a look up will not be necessary and a completely different approach will be implemented.

The video result has me impressed the most. I didn't think the decoder had much to do with it. - Doesn't the shader have to do a lot of work to extract the pixel data from each frame?

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Postby StevenM » Wed Jan 18, 2012 5:15 pm

alphanimal wrote:Also I'd need to access FL's data from the shader (Parameters, BandSpecArray and AudioArray)

I guess that's done through the UniformVariables node?

Also I need some functions to calculate stuff: atan2, sqrt, floor, clamp
Are these available in shader code?


Yes - all you have to do is use uniform variables for parameters- check out Ville's GPU example - it contains both Audio Array and Spectral band examples.

Your math function are there:

This is a useful quick reference -

http://mew.cx/glsl_quickref.pdf

alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Postby alphanimal » Wed Jan 18, 2012 5:22 pm

OK thanks that's useful!

How can I store float (or fixed if necessary) variables for each vertex?


Return to “ZGameEditor Visualizer”

Who is online

Users browsing this forum: No registered users and 1 guest