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

Discuss the ZGameEditor Visualizer plugin for FL-Studio.

Moderator: Moderators

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

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

Post by StevenM »

Alphanimal - is getting familiar with visualizer preset development -

He uploaded this. It will make a really nice official preset, after some parameters are added - very nice work - but I was wondering if there is a way to get the FL Studio user Image Import to work with this. I can't seem to figure it out. can you have a look?
Attachments
PixelParticles1.zgeproj
(20.53 KiB) Downloaded 1091 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The preset is very nice, good work by alphaanimal.

Since it use a script to extract pixels from the bitmap it is tricky to replace the bitmap. Normally ZgeViz replace bitmaps on the OpenGL-API level only and ZGE is not aware of this and do not run scripts again.

I did make it work using a couple of workarounds. I changed it so that the bitmap use a BitmapLoad component from another bitmap (Bitmap2) that initially holds the default bitmap. When the user press "1" on the keyboard it will force Bitmap1 to reinitialize itself. If bitmap2 then is replaced with custom bitmap from the ZgeViz user interface then that bitmap will be used instead of the default. It needs to be in the same resolution though.

So it's far from perfect but better than nothing.

How to use:
1. Select a custom bitmap, it needs to be sized 64x64.
2. Press "1" on the keyboard
Attachments
example
example
pixelparticles.jpg (73.92 KiB) Viewed 28478 times
PixelParticles1.zgeproj
modified script
(20.85 KiB) Downloaded 935 times
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Thank you

Post by StevenM »

This is excellent Ville, thanks - I'll pass on the post to Alphanimal - The script is really nice - runs a bit slow in realtime but the exports are beautiful.
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

here is a nice demo of it too. Nice work in prgress.

http://www.youtube.com/watch?feature=pl ... 8D87veGYqI
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:!:

This kind of project is a perfect fit for shaders. Not only would performance be ( at least ) a tenfold better, it would solve the bitmap problem as well .. since you would pass that to the shader as normal.

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

Post by VilleK »

Cool, found his other demos too:

http://www.youtube.com/watch?v=BURVKuVPBM8
http://www.youtube.com/watch?v=k92nOVHo5mI

Btw, here is the "Vignette"-effect I used as background for the screen shot above. Save it in Clear-folder. I've been experiencing with it and it gives a nice static background for some effects.
Attachments
Vignette.zgeproj
(4.72 KiB) Downloaded 769 times
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

Btw, here is the "Vignette"-effect I used as background
Awesome - this is useful. Should be included with the official clear presets.

I agree this would be excellent for a shader - I would guess that the performance improvement would be incredible too, but - not myself or Alphanimal knows how to do it.
alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Post by alphanimal »

Thanks guys! I think I'll use this thread/forum here from now on :)

I will check out the user bitmap loading and adding parameters. Right now I have a bit of a Windows problem I think. When I double click a zgeproj file in Explorer, it opens it with an old version. It seems impossible to change the associated program to the right path, where I have the current version.

Is there an installer that puts ZGE in Program Files and adds the file type associations automatically? I'll try some registry tweaks until then, but an installer would be a nice addition.

Also I have some bug-reports/feature-requests for the ZgeViz plugin. Where's the right place to put these?

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

Post by StevenM »

Did you get file association worked out ?- I guess when you launch from FL Studio,it opens the preset with a previous version of ZGE you had been using?

I would do one of two things

Delete the old version of ZGE that opens up - windows should prompt you to reset the file association if it can't find the program.

If don't want to delete - try Control Panel Default Programs. Use the - "Associate a file type or Protocol with a program" option.
alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Post by alphanimal »

Yeah thanks I got it sorted out.

1. I didn't remember where I stored the old version.
2. Windows doesn't let you change the program in control panel if the name of the exe file is the same apparently.

I fixed it with regedit (HKEY_CLASSES_ROOT\zgeproj_auto_file\shell\open\command)

Still an installer would be nice imo.
alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Post by alphanimal »

Hey guys!

I added parameters to the pixel particles and created another preset meanwhile... (for those of you that aren't following the thread at IL)

http://www.youtube.com/watch?v=kosmsJ1GxLM

http://www.youtube.com/watch?v=VCe7RtEz3BA


I have some issues with the pixel particles:

1. would it be possible to make use of the user bitmap
- without needing to press a key to update
- with automatic resize so it gets scaled to fit 64x64

2. with the currect CPU usage it's impossible to predict how the effect behaves when rendered. In other words it's god damn slow :)
I tried some optimizations (making static calculations before the loop and not for every pixel etc.), but adding parameters made it even worse.

I'm at 8 fps with disk-shaped images like th FL logo here, but with all 4096 pixels it's even lower.

Do you have any idea what's causing the performance to be that low or how to optimize?

Thanks!
Daniel



edit: Forgot attachments :)
Attachments
Fountain.zgeproj
(4.13 KiB) Downloaded 912 times
PixelParticles.zgeproj
(10.98 KiB) Downloaded 1051 times
Last edited by alphanimal on Sun Jan 15, 2012 5:44 pm, edited 1 time in total.
alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Post by alphanimal »

This from the IL thread:
jmc wrote:
alphanimal wrote:I did some performance tweaks, but it doesn't help much. accessing arrays seems to be quite CPU intensive in ZGE.
From Ville :
Ville wrote:Parameters can bring performance down slightly but it sounds a bit extreme to bring fps to half.

Quick tip is to use local vars. For instance if you have an expression such as

const float damping=0.1;
//followed by many lines using the damping constant, for instance x=x*damping, y=y*damping etc.

Now if you turn damping into a parameter, say Parameter[5], instead of just search-replace every occurence of "damping" to "Parameter[5]" in the source, use a local variable. So:

float damping=Parameter[5];
//then use the original expressions x=x*damping, y=y*damping etc.

Because read from a local var is faster than from an array.

I don't have many array-reads that could be avoided.
Do you think it would be better to use a Model for each pixel and not a loop to process and manually render them?

Also I noticed that it runs much smoother when I compile/run it from ZGE and not run it in ZgeViz.

Do you spot anything bad in the code?

http://pastebin.com/A8xb2u8j
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

As Kjell mentioned, I think a shader is the best way to improve performance.
Can any help a bit with that?

With a model array you can define unique properties/pixel. Recently I discovered that you can send and return models from functions too - this can be really useful. I'm not sure if it will be better or worse performance wise. The shader is almost guaranteed to be much faster though.
alphanimal
Posts: 25
Joined: Sun Feb 27, 2011 1:09 am

Post by alphanimal »

Can you explain in short terms how to implement a shader?
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

This video by Kjell

http://www.youtube.com/watch?v=R2qwSk5Rk1o

shows you how to implement a shader in ZGE. GLSL has a steep learning curve. I'm just started to learn about shaders, since the audio and spectral band are now being direct fed to them too. I learned a lot of scripting and programming languages without too much difficulty in the past.\, However Learning GLSL has been pretty difficult for me so far.

here is a simple GPU shader test that Ville created that uses the spectral band and audio array
Attachments
AudioGpuTest.zgeproj
(1.91 KiB) Downloaded 798 times
Post Reply