Control var value with Paramater[n]?

Discuss the ZGameEditor Visualizer plugin for FL-Studio.

Moderator: Moderators

Mic
Posts: 47
Joined: Mon May 30, 2011 8:10 pm

Control var value with Paramater[n]?

Post by Mic »

Should I be able to do this?

brickColR = Parameters[1];
brickColG = Parameters[2];
brickColB = Parameters[3];

Parameters[1] = 0.5; //brickColR
Parameters[2] = 0.5; //brickColG
Parameters[3] = 0.5; //brickColB

Shader:
varying vec3 BrickColor = vec3(brickColR, brickColG, brickColB);

code compiles, sliders are good - but nothing changes when sliders moved. I think it is quite possible that I have this code

varying vec3 BrickColor = vec3(brickColR, brickColG, brickColB);

in a code path that is only run once on Init, but just want to confirm that controlling a var this way is possible before I do the debug dance :-) TIA,


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

Post by VilleK »

Since shaders and ZGE-expressions live in different runtime environments you need to move the data yourself to the shader. Insert ShaderVariable-components for the variables you need and declare them as "uniform" in your shader to get the values.

Look at Jph's shaders to get an example. In the updated Clear-effects from the thread below he forwards Alpha, Hue, Saturation values from parameters to the shader.

http://forum.image-line.com/viewtopic.p ... 00&t=75362

Let us know if you need more help!
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

I have attached the template script for easy download right from here. Should not be too tough to follow, just ask if you need more info. Have fun.
Attachments
00. TempletScript.zip
(2.73 KiB) Downloaded 653 times
iterationGAMES.com
Mic
Posts: 47
Joined: Mon May 30, 2011 8:10 pm

thanks for the info ...

Post by Mic »

thanks jph and VilleK for the info ... am reading and inwardly digesting ... have been working with Away3d 4, Flash 11 Incubus etc and was trying to design an app that 'produced sophisticated visualizations from an audio input' ..... and then I found ZGame Editor over the weekend .... purchased FL Studio and have not slept since :-)

Mic.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

@Mic

In case you get stuck .. try the attached example ( in FL Studio ). Not exactly sure why you'd want to use shaders for this .. but I guess you're just trying something simple to get started? 8)

K
Attachments
Color.zgeproj
(1.67 KiB) Downloaded 770 times
Mic
Posts: 47
Joined: Mon May 30, 2011 8:10 pm

Post by Mic »

k have taken that apart and have enclosed it with the Shader I am playing with added and connected to the next 3 sliders. Sliders do not work so I added globals to test the Shader vars and no go there either. Comments in Shader4 FragmentShaderSource and blocks easy to comment in/out. Would really appreciate you glancing at it. TIA,

Mic.
Attachments
00.Color_debug.zgeproj
(5.65 KiB) Downloaded 919 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The fragment shader in Shader4 should use "brckColR2" etc. not ("brkColR2" it's a missing "c").

uniform float brckColR2;
uniform float brckColG2;
uniform float brckColB2;

...

color = mix(MortarColor, vec3(brckColR2,brckColG2,brckColB2), useBrick.x * useBrick.y);
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Re: thanks for the info ...

Post by StevenM »

Mic wrote: ..... and then I found ZGame Editor over the weekend .... purchased FL Studio and have not slept since :-)Mic.
Most 3d and graphics apps are really weak in the area of audio input and midi support. I've tried Music Visulization many applications too. Flash was one of them. For the most part - 3D applications require coding scripts, modelers, animators, and a lot of render time .

So far I see the most potential with FL Studio used with ZGE. The power of a DAW linked directly to a game engine has a lot of potential.

I'm still trying to just get a grip on opengl and shaders. I was able to put new lights loaded with parameters in a dll with free basic. It was very easy actually - works good - still need shadows.

I know it's possible, but I probably won't be able to implement real-time opengl shadows(for animation) and bump mapping any time soon. Code examples, dll, shaders... for those topics would be greatly appreciated. Til then I'm going to hack away at it.

The new camera component is fantastic BTW.
Mic
Posts: 47
Joined: Mon May 30, 2011 8:10 pm

Control var value with Paramater[n]?

Post by Mic »

Thanks for finding the bug - should have caught this one :-(. Now working fine and am getting some incredible visualizations!. I posted on the Image Line LoopTalk forum but think I should have asked this one here so sorry for duplicate ....


"According to FLStudio info pane, the Tascam-US2400 controller is sending -200 cents to +200 cents for a channel slider. Have spent hours typing in custom functions to translate to 0 to 1 for a Visualizer color slider. Cannot get it to do anything but jump around like crazy . Any help much appreciated"

I am increasing the ZSamples and RadialSamples of the mesh that the model uses in order to get more detail and beauty :-). Of course I grind to a halt at 100 for both as I do not have a Cray, but want to ask ..... what I really want to do is live music graphics with the beauty (really!) of this amazing tool with the best possible detail it is possible to get. I put the 2 nVidia GTS450 cards in the linked SLI mode for faster OpenGL processing but no difference. I am running a I7 950 with 12 gig of ram. Would a more powerful graphics card help with this? Or is it even possible to get the live music/rendered quality combination?

The Away3d people - http://away3d.com/away3d-4-0-alpha-release-broomstick - have that shallow water demo which is really detailed/accurate, and that runs perfectly here. Flash11 allows code to be uploaded to the GL cpu which I think is how they can do that stuff.

Don't get me wrong - not complaining :-) I'm just sitting here watching huge machinery rotating beyond the stars, and I want to see each individual rivet etc. I actually spent a lot of time rendering with high everything to see how detailed I could get ..... but actually prefer the live stuff at the moment - rendering came out a bit blurry etc.

Thanks very much in advance,

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

Post by StevenM »

sending -200 cents to +200 cents
Do you need to linking to a pitch control? You should use a continuous controller. That something you can set on your hardware controller. I can see the benefit of using a modulation wheel though - it just that the slider would jump around a lot.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: Control var value with Paramater[n]?

Post by Kjell »

Hi Mic,
Mic wrote:I am increasing the ZSamples and RadialSamples of the mesh that the model uses in order to get more detail and beauty :-). Of course I grind to a halt at 100 for both ...
That doesn't sound right. Are you updating the model with a heavy expression each frame or have some complex shader applied? Even when I bump up the ZSamples + RadialSamples to 500 each, I'm getting full 60fps on a system from 2004.

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

Post by VilleK »

I'm glad you get good results so far. Please post images or videos to inspire others (and please the authors ;-) )!

For realtime animation of every vertex in a high-poly mesh you need to write shader code. This is to move the per-vertex computations to the GPU. See the teapot-shader from the ShaderDemo.zgeproj project that's included with ZGameEditor for an example where the vertices are adjusted in the shader. To make it react to music you need to provide the data from SpecBandArray into the shader somehow, perhaps by using a BitmapExpression to send the array data into a texture and then let the shader read the texture and modify the vertex positions based on that.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

@Ville

Perhaps it's time for a ShaderArray component? :wink:

K
Mic
Posts: 47
Joined: Mon May 30, 2011 8:10 pm

re:sending -200 cents to +200 cents etc

Post by Mic »

thanks for responses ... Tascam US2400 has 24 faders and also 24 rotary pots. I wanted to hook up 3 of the faders to BrickColR ,BrickColG, BrickColB. These controls are present on the Visualizer(Master) and work properly. Hardware faders also function correctly as just that on the FLoops mixer i.e reduce and increase channel volume. I am reading the cents thing from the little feedback field underneath the FLStudio File menu, and as I move the hardware fader it reads from -200 cents to +200 cents (whatever that means). In the ZGame code the color parms go from 0 to 1, and I think I read that the Visualizer sliders do the same, so I was trying to create a custom function that translated the -200/+200 to 0/1. You mention that that might be jumpy, but not sure why it would be any different than moving the on screen slider - in fact the hardware fader has a much longer throw, which should make it smoother, right? I was presuming that a hardware controller fader ( Mackie Universal compatible) would be outputting midi volume 0-127 so not sure why FLoops is reading the cents stuff - but not an expert :-). I tried the continuous controller rotary pots with every combination of the mapping formula but the best I could get was to move the Visualizer slider about halfway. I am thinking that everything else is so amazing that this should work! :-)

Concerning the grinding to a halt ... is it OK to post really short videos here to show what is happening? As always thanks in advance .... I spent a couple of hours last night just watching the screen - have a 6 foot by 4 foot DLP projector screen in the studio - I think the word breathtaking is appropriate

Regards,

Mic.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

controller is sending -200 cents to +200 cents for a channel slider. Have spent hours typing in custom functions to translate to 0 to 1
What are the values of Parameter[n] using this controller? If you are getting -200 to 200 then (200+Parameter[n])*.005 gives you 0 to 1 range. However it is my understanding that all controllers should be sending 0-1.

Regarding increasing mesh density to increase detail, this gets a bit tricky,. just remember to multiply the number of polys in your models by the number of models in your whole script to figure the amount of processing it will need. However, just increasing the mesh density on spheres is not always going to give a better look. Some of the scripts use simple models because they are throwing around very many instances of them. everything is a tradeoff so balance is key.

Anyway, here is a start on a ripple sim,. not quite working right yet, however it looks Ok. This is doing the sim. on the CPU and the chrome is applied in a shader on the GPU,. I may work the kinks out this way, and then attempt to recreate the sim in a shader,. . cheers.
Attachments
fluidMesh_003.zip
and .exe and a proto script,. .
(84.57 KiB) Downloaded 696 times
iterationGAMES.com
Post Reply