Logo by Trifox - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. March 28, 2024, 12:03:01 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2 3 ... 5   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: QScripting Fragmentarium  (Read 6394 times)
Description: RFC:QScripting Fragmentarium
0 Members and 1 Guest are viewing this topic.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« on: July 01, 2015, 10:55:14 AM »

here is what I have so far...

in a command shell I type...
Code:
./Fragmentarium-1.0.8 -s test.fqs
test.fqs is a text file that looks like this...
Code:

// Fragmentarium qscript
// 3Dickulus 06/30/15

app.loadFragFile("./My_Params/new-Mandelbulb-anim.frag");
app.setAnimationLength( 10 );
app.setTileWidth(64);
app.setTileHeight(36);
app.setTileMax(10);
app.setSubFrames(10);
app.setOutputBaseFileName("./test.png");
app.setFps(25);
app.setStartframe(0);
app.setEndframe(24);
app.setPreview(false);
app.setAnimation(true);
// begin rendering
app.tileBasedRender();

and that automatically renders all of the frames for a 10 second animation at 25 fps
you can omit the first line in the script file and run it with the frag file on the commandline like...
Code:
./Fragmentarium-1.0.8 -s test.fqs ./My_Params/new-Mandelbulb-anim.frag
and it does the same thing. I have basically exposed the parts of the hires/animation dialogue required for rendering a frame or a range of frames from any frag file. Given that this works quite well I think it will be easy to do in server/client mode too.

The scripting language spec is here, http://www.ecma-international.org/ecma-262/6.0/index.html, java uses the same base spec I think.
EDIT:
Quote from: ECMA-262 6th Edition link=http://www.ecma-international.org/ecma-262/6.0/index.html
ECMAScript is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript (Microsoft). The language was invented by Brendan Eich at Netscape and first appeared in that company’s Navigator 2.0 browser. It has appeared in all subsequent browsers from Netscape and in all browsers from Microsoft starting with Internet Explorer 3.0.

Errors with fqscript line numbers are reported in the log window smiley

done with less than 50 lines of code added to Fragmentaium sources cheesy

I would like to get some input from the community before I go any further.
« Last Edit: July 01, 2015, 08:37:48 PM by 3dickulus, Reason: assumtion » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Adam Majewski
Fractal Lover
**
Posts: 221


WWW
« Reply #1 on: July 01, 2015, 04:18:36 PM »

it would be nice to have scripting language inside program.

Adam

https://en.wikibooks.org/wiki/Fractals/fragmentarium
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #2 on: July 01, 2015, 08:17:52 PM »

Yes, very simple to do (I think), this is just the start originating from a request by Patryk for all of those functions on the commandline, I felt it would be more productive to just have one commandline option... a script file wink

Should it be compile/execute as you type like evaldraw/shadertoy or a compose/save/execute scenario ?

What other functions() should be exposed ?
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #3 on: July 01, 2015, 09:36:09 PM »

Nice! I did essentially the same with Structure Synth, also using the QScriptEngine: http://blog.hvidtfeldts.net/index.php/2010/11/scripting-in-structure-synth/

I imagine that you'd want to make it possible to script the uniforms somehow. Either by making it possible to render one frame at time, and then change some uniforms and repeat in a for-loop (that was the approach I used in Structure Synth), or by making it possible to provide a JavaScript callback function that updates the uniforms before each frame is rendered.
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #4 on: July 01, 2015, 11:24:06 PM »

I'm not sure how far I will take this, as it is right now it only takes one line of code to expose a function for script use and technically it is possible right now to render one frame at a time while making adjustments in a for(){} loop, (see link in first post re:language spec) just allow access to...
Code:
variableEditor->setSettings( settings );
...where settings is a list of variables and values just like in a parameters file or preset wink and then call tileRender() for a single frame (start == finish).

I tried using the QJScript class, it works but it segfaults on exit every time, QScript does not seem to have this problem.
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #5 on: July 02, 2015, 01:53:10 AM »

added a few functions...
Code:
// sets current time to 0
app.rewind();
// starts animating if keyframes and/or easing curves or time var in GLSL are present and length is something
app.play();
// duh ;)
app.stop();

// sets multiple parameters where String follows the format of a parameters file
app.setParameters(String);

// sets a 1,2,3,4 component parameter
app.setParameter1("RotAngle", 120.31622);
app.setParameter2("SpotLightDir", 0.63626,0.5);
app.setParameter3("Target", -5.2432,4.25801,-0.607125);
app.setParameter4("SpotLight", 1.0,1.0,1.0,1.0);

haven't tested extensively but seems to work wink

EDIT: two modes seem apparent
1> animating is controlled by the keyframes and easing curves in the loaded frag file
2> everything is controlled in the script, this would mean always rendering at frame/time 0 with "Animation = false" and modifying the output filename and parameters as needed before calling
Code:
app.tileBasedRender();
I don't know if the script control will present a conflict with time tick incrementing
:ENDEDIT

QScript can also load QtDesigner ui files and exploit the signal/slot mechanism in Qt, this could be used for developing very specialized control interface plugins.

« Last Edit: July 02, 2015, 05:41:39 AM by 3dickulus, Reason: modes » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #6 on: July 02, 2015, 03:17:02 PM »

it would be nice to have scripting language inside program.

Adam

https://en.wikibooks.org/wiki/Fractals/fragmentarium

as requeseted wink

EDIT: on err cursor jumps to line in editor wink
v1.0.8 source code is available on my website.


* fqscript.jpg (155.48 KB, 963x608 - viewed 263 times.)
« Last Edit: July 03, 2015, 07:21:24 AM by 3dickulus » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #7 on: July 04, 2015, 01:19:11 AM »

This is working very well, I should have done it a long time ago.
@Syntopia, I swiped the pad() function so my test script looks like this now...
Code:
// Fragmentarium qscript
// 3Dickulus 07/04/15

// pad function from http://blog.hvidtfeldts.net/index.php/2010/11/scripting-in-structure-synth/
function pad(number) {
   number = number + ''; // convert to string
   while (number.length < 4) { number = "0" + number; }
   return number;
}

// frame specs
function setFrameSpec(w,h,m,s) {

// set the tile buffer size
  app.setTileWidth(w);
  app.setTileHeight(h);
// set tile multiplier
  app.setTileMax(m);

// how many frames to accumulate
  app.setSubFrames(s);
}

// starting point
function init(){

// uncomment to load a frag file, this will open a new tab in Fragmentarium
//  app.loadFragFile("./My_Params/new-Mandelbulb-anim.frag");

// used to calculate range frames and/or total frames
  app.setFps(25);
// this number should be => EasingCurve max frame / fps
  app.setAnimationLength( 10 );

// false = save images
// true = open a preview window for EACH image (be careful)
  app.setPreview(false);

// true = animation gets control from frag
// false = animation gets control from cmd script
  app.setAnimation(false);

// setting both to 0 tells Fragmentarium to not adjust the output filename
  app.setStartframe(0);
  app.setEndframe(0);
}

// call our startup function
init();
// set how many frames (seconds x fps)
max = 10; // just a few for testing

for (i = 0; i <= max; i+=1) {
// what kind of tiled/frame to render
  setFrameSpec(64,36,10,100);
// adjust parameter(s)
  app.setParameter("RotAngle", i*18);
// we need to adjust the filename for each frame
  app.setOutputBaseFileName("./test." + pad(i) + ".png");
// render an image
  app.tileBasedRender();
}

I am amazed a t how easy this was to implement , thank you (again!) Syntopia cheesy

what it means is that all variables available in a preset are also available to cmd script, I'm not a java programmer but I think some of you folks will be very happy with this latest hack. I'm sure it could go deeper.

Currently only available as source code but I'll try to get the win/mac executables asap wink bermarte?

 A Beer Cup
« Last Edit: July 05, 2015, 12:24:55 AM by 3dickulus, Reason: script update with comments » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #8 on: July 05, 2015, 10:23:35 AM »

Ok had some time to play with it and I have some promising results...

Test 0:  cmd script control only
Script:test0.fqs
Result:test.0.mp4

Test 1:  frag animation control only
Script:test1.fqs
Result:test.1.mp4

Test 2:  cmd script control together with frag animation control
Script:test2.fqs
Result:test.2.mp4

...so keyframes and parameter morphing play nice together with script control cheesy

Edit: parameter setting functions in app object
    void setParameter(name, bool)
    void setParameter(name, int)
    void setParameter(name, float)
    void setParameter(name, float, float )
    void setParameter(name, float, float , float)
    void setParameter(name, float, float , float, float)
« Last Edit: July 07, 2015, 03:06:29 AM by 3dickulus, Reason: app object » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #9 on: July 08, 2015, 06:50:09 AM »

Had a bug, webserver/conscience issue, the Fragmentarium-1.0.8 packages are now available Sorry for the inconvenience sad

The Command Script editor now has a Stop button but there is one caveat...

When called from the cmdline in a console window as "Fragmentarium-1.0.8 -s testscript.fqs myAnimation.frag" you can't stop it except from [ctrl+c] in the console window, so the stop button is only working when the Script Editor is visible, the idea is that one would develop and test a script in the editor and then run it on a number of machines to render batches of frames unattended, but I'm sure an intrepid programmer could use QtDesigner to create their own control window wink

The Stop  button works like this...

1) Select Stop then
  1a) wait for the current image to finish, image is saved.
  1b) select abort in the progress dialog, image is not saved.
 A Beer Cup
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #10 on: July 25, 2015, 12:02:44 PM »

So far so good...
This is a very short test of applying a set of frames to a sampler2d parameter using FQS...  voila! animated surface texture.
http://www.digilanti.org/fragmentarium/fqScript/sampler2d-test.mp4 1948499 Jul 25 02:48

here is the sampler2d-test.fqs file...
Code:
// Fragmentarium qscript
// testing sampler2d parameter
// 3Dickulus 07/25/15

// pad function from http://blog.hvidtfeldts.net/index.php/2010/11/scripting-in-structure-synth/
function pad(number) {
   number = number + ''; // convert to string
   while (number.length < 5) { number = "0" + number; }
   return number;
}

// frame specs
function setFrameSpec(w,h,m,s) {
  // set the tile buffer size
  app.setTileWidth(w);
  app.setTileHeight(h);
  // set tile multiplier
  app.setTileMax(m);
  // how many frames to accumulate
  app.setSubFrames(s);
}

seconds = 10;
fps = 25;

// starting point
function init(){
  // used to calculate range frames and/or total frames
  app.setFps(fps);
  // this number should be => EasingCurve max frame / fps
  app.setAnimationLength( seconds );

  // false = save images
  // true = open a preview window for EACH image (be careful)
  app.setPreview(false);

  // false = no control from frag
  // true = control from frag
  app.setAnimation(true);

  // begin
  app.setFrame(0);
  app.setStartFrame(0);
  app.setEndFrame(0);
}

// call our initialization function
init();

// set how many frames (seconds x fps)
maxFrames = seconds * fps;

// Fragmentarium will create our filename from this
app.setOutputBaseFileName("./anim/test.png");

// iterate frame tick up to maxFrames
for (i = 1; i <= maxFrames; i+=1) {

  // set the current frame
  app.setFrame(i);

  // size of tiled/frame to render
  setFrameSpec(64,36,10,10);

  // adjust parameter(s)
  app.setParameter( "myTexture = ./My_Params/InvestigateThis/anim/InvestigateThis." + pad(i) + ".png" );
  // setting the sampler2d with a new texture requires rebuilding the shader (locked var)
  app.initializeFragment();

  // if the user wants to stop rendering break before next image
  if(!app.scriptRunning()) break;

  // render and save an image
  app.tileBasedRender();

}
« Last Edit: July 25, 2015, 09:15:09 PM by 3dickulus » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #11 on: July 26, 2015, 01:42:48 AM »

This is a list of fqScript commands encapsulated by the script "app" object that will be available in v1.0.9 release, beta testers ?


General commands

void setFrame(int);
    Sets the current frame number.

int getFrame();
    Returns the current frame number.

void loadFragFile(String);
    Opens a new editor tab, loads the named fragment file, initializes default preset, initializes keyframes and easing curves if the file contains these settings.

bool initializeFragment();
    Returns success or fail. Must be called after altering a locked variable before rendering an image.


Parameter commands

void setParameter(String);
    Set a parameter from String in the form of "parameter = value" also accepts parameter file formated string.

void setParameter(String, bool);
    Sets a boolean parameter where String is the parameter name and bool is TRUE or FALSE

void setParameter(String, int);
    Sets an integer parameter where String is the parameter name and int is any integer.

void setParameter(String, x);
    Sets a float parameter where String is the parameter name and x is any floating point number.

void setParameter(String, x, y);
    Sets a float2 parameter where String is the parameter name and x,y is any floating point number.

void setParameter(String, x, y, z);
    Sets a float3 parameter where String is the parameter name and x,y,z is any floating point number.

void setParameter(String, x, y, z, w);
    Sets a float4 parameter where String is the parameter name and x,y,z,w is any floating point number.

String getParameter(String);
    Returns a string representing the value(s) for the named parameter, user must parse this into usable values.


Hires image and animation dialog commands

void setAnimationLength(int);
    Sets the total animation duration in seconds.

void setTileWidth(int);
void setTileHeight(int);

    Sets the tile width and height.

void setTileMax(int);
    Sets the number of row and column tiles, this value squared = total tiles.

void setSubFrames(int);
    Sets the number of frames to accumulate.

void setOutputBaseFileName(String);
    Sets the filename for saved image, if script has total control this must be set for every frame, if animation is using frag file settings, keyframes etc., then this only needs to be set once and Fragmentarium will add an index padded to 5 digits.

void setFps(int);
    Sets the frames per second for rendering.

void setStartFrame(int);
    Sets the start frame number for rendering a range of frames.

void setEndFrame(int);
    Sets the end frame number for rendering a range of frames.

void setAnimation(bool);
    FALSE sets animation to script control exclusively. TRUE enables keyframes and easing curves.

void setPreview(bool);
    TRUE will preview frames in a window on the desktop instead of saving image files.


Control commands

bool scriptRunning();
    Returns FALSE when the user selects the [Stop] button in the script editor. For user implemented test to break out of the script control loop.

void stopScript();
    For user implemented test to break out of the script control loop. file not found, initialization fail etc.

void tileBasedRender();
    Begins rendering the current frame or range of frames using current state.

« Last Edit: August 02, 2015, 04:31:28 PM by 3dickulus » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #12 on: July 26, 2015, 01:49:21 AM »

i still wonder why no one is using synthclipse, it has a build in  ful fledged opengl accessible javascript parser included, making it easy to combine multiple shader with similar functionality ... wink just sayin'  its for the fun, i see that, so i hope no harm done!
Logged

---

divide and conquer - iterate and rule - chaos is No random!
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #13 on: July 26, 2015, 02:05:01 AM »

I think the more complex a program gets, the more intimidating it is or perhaps the complexity makes it difficult to get it organized in the average user's head. I liked Eclipse but it didn't feel comfortable as an IDE, Synthclipse is Eclipse? that has been tailored to GLSL.

I would like Fragmentarium to be as friendly for the novice "I just want to make pretty pictures" as it might be for the hard core hackers "I want total control".

Fragmentarium-1.0.9 is up.     Source code and win exe. cheesy
« Last Edit: July 26, 2015, 07:23:46 AM by 3dickulus, Reason: link » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Patryk Kizny
Global Moderator
Fractal Fertilizer
******
Posts: 372



kizny
WWW
« Reply #14 on: August 05, 2015, 05:42:01 PM »

It looks pretty cool and I should have gotten familiar with it sooner.

Few questions / notes
1) Does the QS window have to be modal = disables controlling everything below? I would love to keep it opened and execute small scripts not having to open it multiple times, load script, then close.
2) Would that be possible to add 5 buttons to GUI where you could load scripts into, then press button to execute connected script. plus one button to STOP a running script? That would be so cool!

Logged

Visual Artist, Director & Cinematographer specialized in emerging imaging techniques.
Pages: [1] 2 3 ... 5   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
having fun with fragmentarium Images Showcase (Rate My Fractal) ker2x 5 2246 Last post January 14, 2012, 12:26:39 PM
by ker2x
Fragmentarium 0.9.1 Released Fragmentarium « 1 2 » Syntopia 19 4570 Last post June 10, 2012, 10:27:46 AM
by Syntopia
Help in Fragmentarium Fragmentarium Tim Emit 2 828 Last post January 15, 2013, 10:05:24 PM
by Tim Emit
Fragmentarium español Leonrott 4 3438 Last post January 09, 2014, 02:07:16 PM
by stereoman
I/O for fragmentarium Fragmentarium Patryk Kizny 6 1495 Last post November 13, 2015, 04:02:17 AM
by 3dickulus

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.634 seconds with 25 queries. (Pretty URLs adds 0.021s, 2q)