model

The model section represents a 2D or 3D model. By default, the model object serves as a preview and cannot be used any further. The model section can however be combined with the keyword image or animation, making the render available as a texture in the remainder of the script, but forcing it to have a fixed resolution, specified by the dimensions modifier.

Its syntax can be one of:

model <name> : <modifier1, modifier2, ...>;
model image <name> : <modifier1, modifier2, ...>;
model animation <name> : <modifier1, modifier2, ...>;

The available modifiers are listed below.

Modifiers

You can specify a subset of the following modifiers. Only the vertex specification is mandatory.

  • fragment_data(<type>) – specifies the data type that will be used to transfer data between the vertex and fragment shader. The type can only be float, vec2, vec3, vec4, or a simple structure consisting of these types. The value passed to the fragment function will be interpolated based on proximity to each vertex like OpenGL varyings.
  • vertex(<function>, <primitive type>, <vertex count / vertex list>) – specifies the sequence of the model's vertices. function is a GLSL function that receives either the index of the current vertex as int or a single vertex from the supplied vertex list, and returns that vertex's gl_Position (vec4) – meaning that any coordinate transformations must be applied in this function. If fragment_data has been specified (as non-void), the function's first argument must be an output parameter of fragment data type. The possible primitive types are points, lines, line_strip, line_loop, triangles, triangle_strip, and triangle_fan.
    vec4 vertexFunction(out FragmentDataType fragmentData, int vertexIndex);
    vec4 vertexFunction(out FragmentDataType fragmentData, in VertexListType vertexData);
    vec4 vertexFunction(int vertexIndex); // if no fragment data type set
  • fragment(<function>) – specifies the function that computes the fragment color and returns it as vec4. If fragment_data has been specified (as non-void), the function has one parameter – the fragment data. Otherwise it has no parameters. If no fragment function is specified, the model will be rendered solid white.
    vec4 fragmentFunction(in FragmentDataType fragmentData);
    vec4 fragmentFunction(); // if no fragment data type set
  • vertex_animated(<function>, <primitive type>, <vertex count / vertex list>) – same as vertex, but allows the vertex position or fragment data to change over time. The vertex function receives an additional float parameter with the current time in seconds. Modifier invalid for model image
    vec4 vertexFunction(out FragmentDataType fragmentData, int vertexIndex, float time);
  • fragment_animated(<function>) – same as fragment, but allows the fragment color to change over time. The fragment function receives an additional float parameter with the current time in seconds. Modifier invalid for model image
    vec4 fragmentFunction(in FragmentDataType fragmentData, float time);
  • background(<color>) – specifies the background color, which is used to fill the viewport before drawing the model. Black with zero alpha is the default
  • blend(<mode>) – specifies the blending mode to be used. The possible values are:
    • none
    • transparency
    • transparency_premultiplied
    • additive
    • multiplicative
    • min
    • max
  • depth(<true / false>) – enables or disables the depth buffer (enabled by default)
  • cull(<true / false>) – enables or disables backface culling (disabled by default)
  • wireframe(<true / false>) – enables or disables wireframe mode (disabled by default)
  • multisample(<factor>) – enables (>0) or disables (0) multisample anti-aliasing. The value of the argument is the maximum number of samples per pixel
  • heavy_mode(<true / false>) – this option is required for computationally intensive shaders, where rendering time may exceed 1 second. Without it, there is a risk of GPU driver crash

Image/animation modifiers

The following modifiers are only available with the image or animation keyword.

  • dimensions(<width, height>) – specifies the dimensions of the viewport
  • filter – see image filter modifier
  • map – see image map modifier
  • hidden – see image hidden modifier
  • resizable – see image resizable modifier
  • full_range – see image full_range modifier