As with Fragx shaders in JSX scripts it is possible to use Commands. Commands are special type of comments in the JavaScript, starting from "//!" or from "/*!". They are metadata describing various aspects of the JSX scripts.
Commands have syntax derived from XML, apart from Uniform Controls - which have syntax compatible with the Fragmentarium. Most of the XML-based commands do not have closing tag (although you can put "/" before ">" if you want). Only exceptions are "<info></info>" and "<preset></preset>" Commands.
This document describes available commands, their syntax and application.
Uniform Controls (UC) are used only at the end of variable declarations. Their purpose is to make possible to change variable's values during script execution by user controlled widgets/controls/components. Each UC has corresponding widget (or set of widgets) in the Uniform Controls View. There are few types of UCs with different names and parameters. They are described in depth in separate document.
Although there are no uniform variables in the JavaScript, the name "Uniform Control" is also used for Commands describing UI controls of JavaScript variables. The reason why I've decided to use the same name is simple: unification. These Commands have the same purpose, share the same controls, and are displayed in the same View (Uniform Controls View) as Fragx' Uniform Controls.
examples:
var currentShapeID = 0; //! islider[0, 5, 11] var wireframeMode = false; //! checkbox[false] var coneRadius = 0.5; //! slider[0.1, 3, 10]
Group commands are used to group UCs on separated tabs on the Uniform Controls View. Every uniform variable, declared after group command, belongs to that group.
syntax:
//! <group name="GROUP_NAME"> // or with optional slash: //! <group name="GROUP_NAME"/> // IMPORTANT: never use closing tag: </group>
examples:
//! <group name="Group #1"/> var currentShapeID = 0; //! islider[0, 5, 11] var wireframeMode = false; //! checkbox[false] //! <group name="Group #2"/> var coneRadius = 0.5; //! slider[0.1, 3, 10]
Info command is intended for script description, license and author's name.
syntax:
/*! * <info> * some text. * </info> */
examples:
/*! * <info> * Author: Kamil Kolaczynski * Title: Mandelbrot Set * Description: This is classical Mandelbrot Set with Orbit trap coloring. * License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License * </info> */
Preset commands are automatically generated by Synthclipse whenever you save some presets using the Save button in the Uniform Controls View:
In contrast to Fragx shaders, in JSX scripts no presets are loaded automatically. You must load them explicitly using Synthclipse.loadPreset() - for JavaScript presets - or GLSLProgram.loadPreset(), FragxRenderer.loadPreset() - for GLSLPrograms and FragxRenderers, respectively.
syntax:
/*! * <preset name="PRESET_NAME"> * UNIFORM_NAME_1 = VALUE_1 * UNIFORM_NAME_2 = VALUE_2 * UNIFORM_NAME_3 = VALUE_3 * ... * </preset> */ // or if preset is saved in a separate file: //! <preset file="/path/to/some.preset" />
examples:
/*! * <preset name="Default"> * coneRadius = 0.1 * currentShapeID = 10 * wireframeMode = false * </preset> */ //! <preset file="D:/Revers/Synth/my_shader.preset" />
Messages commands are used to highlight some fragments in a code. Their role is only informative. They are mostly autogenerated by Synthclipse importers.
syntax:
//! INFO: message //! WARNING: message //! ERROR: message
examples:
//! INFO: text of an info message //! WARNING: text of a warning message //! ERROR: text of an error message