### GLSL Built-in Types and Functions Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/tutorials/READMEold.md A reference guide to the fundamental built-in data types and common mathematical functions available in GLSL (OpenGL Shading Language), essential for writing efficient shaders that run on graphics processors. ```APIDOC GLSL Built-in Types: vec2: 2-component vector vec3: 3-component vector vec4: 4-component vector mat2: 2x2 matrix mat3: 3x3 matrix mat4: 4x4 matrix GLSL Built-in Functions: float length(vec v): Returns the length of a vector. float distance(vec v1, vec v2): Returns the distance between two points/vectors. vec normalize(vec v): Returns a vector with the same direction but a length of 1. pow(x, y): Returns x raised to the power of y. exp(x): Returns e (the base of natural logarithms) raised to the power of x. sqrt(x): Returns the square root of x. abs(x): Returns the absolute value of x. Trigonometric Functions: sin(angle): Sine of angle. cos(angle): Cosine of angle. tan(angle): Tangent of angle. atan(y, x): Arc tangent of y/x. acos(x): Arc cosine of x. asin(x): Arc sine of x. ``` -------------------------------- ### Simulating GPU Pixel Processing Loop (Mental Model) Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/tutorials/READMEPrev.md This GLSL code snippet illustrates a conceptual mental model of how a GPU might process pixels by iterating through a 3D space. It's important to note that this is a simplified representation for understanding, as actual GPU processing is highly parallel and not sequential. ```GLSL //Note this is just a mental model for(float x = -1.0; x <1.0; x+=0.001) { for(float y = -1.0; y <1.0; y+=0.001) { for(float z = -1.0; z <1.0; z+=0.001) { float distanceToObject = scene(vec3(x, y, z)); } } } ``` -------------------------------- ### Simplified Sphere SDF using Length Function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/tutorials/READMEPrev.md This GLSL snippet provides a more concise Signed Distance Function (SDF) for a sphere. By leveraging the `length()` function, it directly calculates the distance of the pixel 'p' from the origin and subtracts the sphere's radius, simplifying the previous approach while achieving the same result. ```GLSL scene(vec3 p) { return length(p - 0.2); } ``` -------------------------------- ### Defining a Sphere SDF (Initial Approach) Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/tutorials/READMEPrev.md This GLSL snippet defines a basic Signed Distance Function (SDF) for a sphere. It calculates the distance from the origin to the current pixel position 'p' and subtracts a fixed 'size' to determine if 'p' is inside or outside the sphere. Positive values indicate outside, negative values inside, and zero is on the surface. ```GLSL scene(vec3 p) { float size = 0.2; return distance((vec3(0.0, 0.0, 0.0), p) - size); } ``` -------------------------------- ### Shader Park GLSL line function API Signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/geometries/line.md Provides the API signature for the `line` function in Shader Park, a GLSL utility function. It takes a point `p`, the start and end points of the line (`start`, `end`), and a `width` parameter. This function is typically used for distance calculations or rendering effects related to lines. ```glsl float line(vec3 p, vec3 start, vec3 end, float width); ``` -------------------------------- ### GLSL Function Signature for simpleLighting Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/lighting/simpleLighting.md Defines the signature for the `simpleLighting` function, which is used to calculate lighting in a shader. It takes a position vector, a normal vector, and a light direction vector as input. An interactive example demonstrating its use is provided via an embedded Shader Park sculpture. ```glsl float simpleLighting(vec3 p, vec3 normal, vec3 lightDirection); ``` -------------------------------- ### GLSL Geometry: torus SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for a torus Signed Distance Field (SDF) function. This function calculates the signed distance from a point to the surface of a torus. ```GLSL float torus(vec3 p, vec2 size); ``` -------------------------------- ### GLSL Geometry: line SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for a line Signed Distance Field (SDF) function. This function calculates the signed distance from a point to a line segment. ```GLSL float line(p, vec3 start, vec3 end, float width); ``` -------------------------------- ### GLSL Geometry: cylinder SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for a cylinder Signed Distance Field (SDF) function. This function calculates the signed distance from a point to the surface of a cylinder. ```GLSL float cylinder(vec3 p, vec2 size); ``` -------------------------------- ### GLSL Operation: smoothAdd SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for the `smoothAdd` operation on two Signed Distance Fields (SDFs). This function performs a smooth union of two SDFs, blending their surfaces over a specified amount. ```GLSL float smoothAdd(float obj1, float obj2, float amount); ``` -------------------------------- ### GLSL Operation: mix (Interpolation) SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for the `mix` operation on two Signed Distance Fields (SDFs). This function interpolates between two SDFs based on a given amount, useful for blending shapes. ```GLSL float mix(float obj1, float obj2, float amount); ``` -------------------------------- ### Get Ray Direction in GLSL Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/math/getRayDirection.md Returns the direction of the ray from the camera in Shader Park GLSL. This function is useful for raymarching and other camera-dependent calculations within a shader. ```glsl vec3 getRayDirection(); ``` -------------------------------- ### GLSL Operation: add (Union) SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for the `add` (union) operation on two Signed Distance Fields (SDFs). This function combines two SDFs, returning the minimum distance, effectively creating a union of the shapes. ```GLSL float add(float obj1, float obj2); ``` -------------------------------- ### GLSL Operation: intersect SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for the `intersect` operation on two Signed Distance Fields (SDFs). This function combines two SDFs, returning the maximum distance, effectively creating an intersection of the shapes. ```GLSL float intersect(float obj1, float obj2); ``` -------------------------------- ### GLSL Operation: subtract (Difference) SDF Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Example declaration for the `subtract` (difference) operation on two Signed Distance Fields (SDFs). This function subtracts one SDF from another, effectively creating a boolean difference of the shapes. ```GLSL float subtract(float obj1, float obj2); ``` -------------------------------- ### GLSL hsv2rgb Function Signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/color/hsv2rgb.md Converts a color from HSV (Hue, Saturation, Value) color space to RGB (Red, Green, Blue) color space. This function is commonly used in graphics programming for color manipulation and is demonstrated with an interactive example in Shader Park. ```GLSL vec3 hsv2rgb( in vec3 c ); ``` -------------------------------- ### Get Mouse Ray Intersection Point in GLSL Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/mouse-interactions/mouseIntersection.md This GLSL function returns a `vec3` representing the 3D world-space coordinates where the current mouse ray intersects the rendered scene. It is commonly used for implementing interactive features, object picking, or direct manipulation within Shader Park sculptures. ```glsl vec3 mouseIntersection(); ``` -------------------------------- ### JavaScript Syntax for input() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/input/input.md Illustrates the various ways to call the `input()` function in Shader Park, showing different argument combinations for defining the slider's initial value and range. ```js input(startValue, minValue, maxValue); input(startValue); input(); ``` -------------------------------- ### APIDOC: expand() Function Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/expand.md Comprehensive API documentation for the `expand()` function, detailing its syntax and the `amount` parameter, including its type and valid range. ```APIDOC expand(amount); amount: Number - value from 0 to 1.0 to expand by ``` -------------------------------- ### API Reference for input() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/input/input.md Detailed API specification for the `input()` function, outlining its parameters, their expected data types, and default values. This reference helps developers understand how to configure the slider's behavior. ```APIDOC input([startValue: Float = 0], [minValue: Float = 0], [maxValue: Float = 1.0]) startValue: Float - The initial value for the slider. Defaults to 0. minValue: Float - The minimum value for the slider's range. Defaults to 0. maxValue: Float - The maximum value for the slider's range. Defaults to 1.0. ``` -------------------------------- ### grid() Function Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/grid.md Details the parameters accepted by the `grid()` function, including their types and descriptions. ```APIDOC count: Number - number of grid sections. ranges from 0 to any number scale: Float - size of the grid sections thickness: Float - thickness of the grid sections ``` -------------------------------- ### JavaScript: expand() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/expand.md Illustrates the basic syntax for using the `expand()` function in JavaScript within Shader Park, which takes a single `amount` parameter. ```js expand(amount); ``` -------------------------------- ### glslFunc() Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/glsl/glslFunc.md Basic syntax for calling the glslFunc function. ```js glslFunc(func); ``` -------------------------------- ### mirrorN() Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/mirrorN.md This section details the parameters accepted by the `mirrorN()` function. It specifies the type and a brief description for each parameter, including their valid ranges and purpose. ```APIDOC count: Number - the number of times to mirror the space. Ranges from 0 to any number spacing: Float - how much spacing to put between each mirror. ``` -------------------------------- ### fractalNoise() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/algorithms/fractalNoise.md Provides detailed API documentation for the `fractalNoise` function, outlining its parameters and their respective types and descriptions. ```APIDOC fractalNoise(position) position: vec3 - the position to sample noise ``` -------------------------------- ### metal() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/metal.md Detailed API documentation for the `metal()` function, including its parameters, types, and value ranges. ```APIDOC metal(value) value: Float (0.0 to 1.0) ``` -------------------------------- ### glslFuncES3 API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/glsl/glslFuncES3.md Detailed API documentation for the `glslFuncES3` function, including its parameters and return types. ```APIDOC glslFuncES3(func) Parameters: func: String - A String containing a GLSL function. Returns: Function - An encapsulated version of func. Any arguments given to this function will be forwarded as arguments to the provided glsl function. ``` -------------------------------- ### glslFunc() Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/glsl/glslFunc.md Details of the parameters accepted by the glslFunc function. ```APIDOC func: String A string containing a GLSL function. ``` -------------------------------- ### API Documentation for line() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/line.md Detailed API documentation for the line() function, including parameter types and descriptions for drawing a line in 3D space. ```APIDOC line(startPosition: Vec3, endPosition: Vec3, thickness: Float) startPosition: x, y, and z starting position of the line endPosition: x, y, and z ending position of the line thickness: thickness of the line ``` -------------------------------- ### Shader Park: Global Constants API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for commonly used mathematical constants available in Shader Park. ```APIDOC PI TWO_PI TAU ``` -------------------------------- ### JavaScript Syntax for glslFuncES3 Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/glsl/glslFuncES3.md Shows the basic syntax for calling the `glslFuncES3` function in JavaScript. ```javascript glslFuncES3(func); ``` -------------------------------- ### setSpace() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/setSpace.md Detailed API documentation for the setSpace() function, outlining its parameters and their expected types for proper usage. ```APIDOC setSpace(space) Parameters: space: Vec3 - coordinate space ``` -------------------------------- ### API Documentation for sphere() Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/sphere.md Provides detailed information about the parameters accepted by the `sphere()` function, including their data types and descriptions. ```APIDOC sphere(size): size: Number - size of the sphere ``` -------------------------------- ### API Reference for blend() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/blend.md Provides a comprehensive overview of the `blend` function's API. It details the required `amount` parameter, its type, and valid range for controlling the blending operation. ```APIDOC blend(amount) Parameters: amount: Type: Number Description: value from 0 to 1.0 to blend ``` -------------------------------- ### toSpherical() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/math/toSpherical.md Detailed API documentation for the `toSpherical()` function, outlining its parameters and return type. ```APIDOC toSpherical(space): space: Vec3 - coordinate space Returns: Vec3 - spherical coordinate space ``` -------------------------------- ### Shader Park: GLSL Integration API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions that allow direct integration or manipulation of GLSL code within Shader Park, including custom functions and SDFs. ```APIDOC glslFunc() glslFuncES3() glslSDF() ``` -------------------------------- ### mirrorN() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/mirrorN.md This snippet provides the basic syntax for calling the `mirrorN()` function in JavaScript. It shows the required parameters: `count` for the number of mirrors and `spacing` for the distance between them. ```js mirrorN(count, spacing); ``` -------------------------------- ### Shader Park torus() Function Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/torus.md Details the parameters required for the `torus()` function in Shader Park, specifying their types and descriptions. ```APIDOC torus( outerRingSize: Number - size of the outer ring, innerRingSize: Number - size of the inner ring ) ``` -------------------------------- ### Shader Park mixMat() function API reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/mixMat.md Provides detailed API documentation for the mixMat() function, including its parameters and their types. ```APIDOC mixMat(amount) Parameters: amount: Number - value from 0 to 1.0 to mix ``` -------------------------------- ### JavaScript Syntax for shape() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/shape.md Illustrates the basic syntax for calling the `shape()` function in JavaScript, showing that it takes a function as its primary argument. ```js shape(shape_func); ``` -------------------------------- ### glslSDF Function JavaScript Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/glsl/glslSDF.md Illustrates the basic syntax for calling the `glslSDF` function in JavaScript, showing how it accepts GLSL source code as an argument. ```js glslSDF(glslCode); ``` -------------------------------- ### JavaScript setSpace() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/setSpace.md Illustrates the basic syntax for calling the setSpace() function in JavaScript, showing the required parameter for space transformation. ```javascript setSpace(space); ``` -------------------------------- ### Shader Park: Input - Interactive API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions that provide interactive input data from user actions, such as generic input, mouse position, and mouse intersection points. ```APIDOC input() mouse() mouseIntersection() ``` -------------------------------- ### JavaScript Syntax for sphere() Function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/sphere.md Illustrates the basic JavaScript syntax for invoking the `sphere()` function. ```js sphere(size); ``` -------------------------------- ### fractalNoise() JavaScript Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/algorithms/fractalNoise.md Illustrates the basic syntax for invoking the `fractalNoise` function in JavaScript. ```js fractalNoise(position) ``` -------------------------------- ### grid() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/grid.md Defines the JavaScript syntax for calling the `grid()` function. ```js grid(count, scale, thickness); ``` -------------------------------- ### Shader Park mixMat() function basic syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/mixMat.md Illustrates the basic JavaScript syntax for calling the mixMat() function in Shader Park. ```js mixMat(amount); ``` -------------------------------- ### JavaScript Syntax for line() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/line.md Provides the basic syntax for calling the line() function in Shader Park, specifying its required parameters. ```js line(startPosition, endPosition, thickness); ``` -------------------------------- ### glslFunc() Returns Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/glsl/glslFunc.md Description of the return value of the glslFunc function. ```APIDOC Returns: Function An encapsulated version of func. Any arguments given to this function will be forwarded as arguments to the provided GLSL function. ``` -------------------------------- ### JavaScript Syntax for getRayDirection() Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/input/getRayDirection.md Illustrates the basic syntax for calling the `getRayDirection()` function in JavaScript. ```js getRayDirection(); ``` -------------------------------- ### metal() function JavaScript syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/metal.md Shows the basic JavaScript syntax for calling the `metal()` function in Shader Park. ```js metal(value); ``` -------------------------------- ### glslSDF Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/glsl/glslSDF.md Detailed API specification for the `glslSDF` function, outlining its required parameters and the type of function it returns, which can then be used to forward arguments to the underlying GLSL function. ```APIDOC glslSDF(glslCode) Parameters: glslCode: String - The glsl source code. Returns: Function - A js function of the glslCode. Any arguments given to this function will be forwarded as arguments to the provided glsl function. ``` -------------------------------- ### Shader Park cylinder() Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/cylinder.md Detailed API documentation for the `cylinder()` function in Shader Park, including its overloaded signatures and parameter specifications for creating 3D cylinder primitives. ```APIDOC cylinder(radius, height) Description: Draw a cylinder with the given radius, and height Parameters: radius: Number - radius of the box height: Number - height of the box cylinder(size) Description: Draw a cylinder with the given radius, and height Parameters: size: vec3 - radius, and height ``` -------------------------------- ### APIDOC: setGeometryQuality() Function Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/global-settings/setGeometryQuality.md Detailed API documentation for the setGeometryQuality function, outlining its parameters and their types. ```APIDOC setGeometryQuality(size) Parameters: size: Float (value from 0 to 100. Defaults to 15) ``` -------------------------------- ### Shader Park rotateX() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/rotateX.md Provides detailed API documentation for the `rotateX()` function, including its parameters, types, and expected values. ```APIDOC rotateX(amount: Number) amount: Number - value in radians, which can rotate a full 360° by providing a value from -PI/2 to PI/2 ``` -------------------------------- ### Shader Park: Algorithms API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for algorithmic functions in Shader Park, such as noise generation and spherical distribution. ```APIDOC noise() fractalNoise() sphericalDistribution() ``` -------------------------------- ### Shader Park: Global Settings API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions that control global rendering and quality settings in Shader Park, such as geometry quality, step size, and max iterations. ```APIDOC setGeometryQuality() setStepSize() setMaxIterations() ``` -------------------------------- ### Shader Park: Math Functions API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for common mathematical functions available in Shader Park, including trigonometric, exponential, power, and vector operations. ```APIDOC sin() cos() tan() asin() acos() nsin() exp() log() exp2() log2() pow() sqrt() inversesqrt() mod() fract() abs() sign() floor() ceil() min() max() clamp() mix() smoothstep() length() distance() dot() cross() normalize() reflect() refract() toSpherical() fromSpherical() ``` -------------------------------- ### Shader Park: Lighting API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions that control lighting behavior in Shader Park, including disabling lighting and setting light direction. ```APIDOC noLighting() lightDirection() ``` -------------------------------- ### JavaScript Syntax for setMaxIterations() Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/global-settings/setMaxIterations.md Illustrates the basic syntax for calling the `setMaxIterations()` function in JavaScript, which takes a single integer argument. ```js setMaxIterations(iterations); ``` -------------------------------- ### API Documentation for rotateY() Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/rotateY.md Details the parameters required by the rotateY function, including their types and descriptions. ```APIDOC amount: Number value in radians, which can rotate a full 360° by providing a value from -PI/2 to PI/2 ``` -------------------------------- ### Shader Park: Input - Space and Time API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions that provide access to spatial and temporal input data within Shader Park, such as current space, ray direction, time, and normals. ```APIDOC getSpace() getSpherical() getRayDirection() time() normal() ``` -------------------------------- ### JavaScript Syntax for blend() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/blend.md Illustrates the basic call signature for the `blend` function. It takes a single numeric argument to control the blending amount. ```javascript blend(amount); ``` -------------------------------- ### API Reference for shape() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/shape.md Detailed API documentation for the `shape()` function, including its purpose, parameters, and return value. It describes how the function encapsulates state-changing commands for hierarchical modeling. ```APIDOC shape(shape_func) Description: Creates a new primitive shape. All state changing commands (color, displacement, geometry modes) are encapsulated and will only have an affect within scope of the provided function. Useful for isolating components with their own distortions and materials. Shapes can be nested for hierarchical modeling. Parameters: shape_func: Function - A function which draws a shape. Returns: Function: An encapsulated version of shape_func which will not modify any drawing state outside of its own scope. Note: Any arguments given to this function will be forwarded as arguments to shape_func. ``` -------------------------------- ### Shader Park: Known Issues and Work In Progress Limitations Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Details known limitations and work-in-progress aspects of Shader Park functions, including type restrictions for certain math operations and issues with conditional branching. ```APIDOC length, distance, dot, and normalize work only with with vec3s. pow, mod, min, max, atan, clamp, mix, and smoothstep work only with floats. branching / using if statements that reference built-in variables will not work. Specifically variables like vec2, vec3, vec4, or using input variables like time. ``` -------------------------------- ### mouseIntersection() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/input/mouseIntersection.md Detailed API documentation for the `mouseIntersection()` function, including its purpose and return type. ```APIDOC mouseIntersection(): Description: Provides the location where the mouse intersects the drawn shape. Returns: Vec3 - The position of the mouse intersection. ``` -------------------------------- ### Shader Park noise() function API reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/algorithms/noise.md Comprehensive API documentation for the noise() function in Shader Park, detailing its signature, parameters, and their types and descriptions. ```APIDOC noise(position) position: vec3 - the position to sample noise ``` -------------------------------- ### Shader Park: Geometry Primitives API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for built-in functions to create basic 3D geometric shapes in Shader Park. ```APIDOC sphere() box() boxFrame() torus() line() cylinder() grid() ``` -------------------------------- ### shine() Function API Documentation Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/shine.md Detailed API reference for the `shine()` function, including its purpose, parameters, and value range. This function defines the shininess of a shape, corresponding to the albedo property in PBR. ```APIDOC shine(value) value: Float Description: value from 0.0 to 1.0. Default: ____ ``` -------------------------------- ### JavaScript Syntax for shine() Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/shine.md Basic syntax for calling the `shine()` function in Shader Park, used to set the shininess of a shape. This function is part of the Shader Park API for material properties. ```javascript shine(value); ``` -------------------------------- ### JavaScript Syntax for setGeometryQuality() Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/global-settings/setGeometryQuality.md Defines the basic syntax for calling the setGeometryQuality function in JavaScript within Shader Park. ```js setGeometryQuality(size); ``` -------------------------------- ### Shader Park shell() Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/shell.md API documentation for the `shell()` function, detailing its JavaScript syntax and parameters. This function is used to hollow out a shape and create a shell around it with a specified thickness. ```js shell(thickness); ``` ```APIDOC Parameters: thickness: Type: Number Description: Value from 0.001 to 0.2 ``` -------------------------------- ### Convert HSV to RGB using hsv2rgb() function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/hsv2rgb.md Demonstrates the basic syntax for calling the hsv2rgb function, which converts Hue, Saturation, and Value components into RGB color values. This function is typically used in shader programming contexts. ```js hsv2rgb(inputColor); ``` -------------------------------- ### sphericalDistribution() Function API Reference and Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/algorithms/sphericalDistribution.md Detailed API documentation for the `sphericalDistribution` function, including its JavaScript signature, parameters, and return value for computing distances to points distributed on a sphere. ```js sphericalDistribution(p, numPoints) ``` ```APIDOC Parameters: p: vec3 - a point to sample. numPoints: Float - number of points distributed on the sphere. Returns: Vec4 - x,y,z is the location of the point nearest to p, and w is the distance to that point ( w = distance(xyz,p) ) ``` -------------------------------- ### Shader Park rotateZ() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/rotateZ.md Detailed API documentation for the `rotateZ()` function, outlining its parameters and their types. ```APIDOC rotateZ(amount: Number) amount: Number - Value in radians. Can rotate a full 360° by providing a value from -PI/2 to PI/2. ``` -------------------------------- ### simpleLighting GLSL Function Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Calculates basic lighting for a given point in 3D space. It takes the point's position, its surface normal, and the direction of the light source to compute a lighting value. ```glsl float simpleLighting(vec3 p, vec3 normal, vec3 lightDirection); ``` -------------------------------- ### mixGeo() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/mixGeo.md Defines the syntax for the `mixGeo()` function, which allows for blending between two geometries. It takes an `amount` parameter, a Number from 0 to 1.0, to control the mix ratio. ```js mix(amount); ``` -------------------------------- ### setMaxIterations() API Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/global-settings/setMaxIterations.md Details the parameters required by the `setMaxIterations()` function, specifying the type and valid range for the `iterations` argument. ```APIDOC setMaxIterations(iterations) iterations: Int - value from 0 to any value ``` -------------------------------- ### getRayDirection() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/input/getRayDirection.md Provides the API specification for the `getRayDirection()` function, detailing its signature and return value. ```APIDOC getRayDirection(): Vec3 Returns: Vec3: direction the camera is pointing. ``` -------------------------------- ### JavaScript Syntax for setStepSize Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/global-settings/setStepSize.md Illustrates the basic JavaScript syntax for calling the `setStepSize` function in Shader Park, which is used to control the raymarching step size. ```javascript setStepSize(size); ``` -------------------------------- ### displace() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/displace.md Illustrates the different ways to call the `displace()` function in Shader Park, accepting either individual coordinate components (x, y, z) or a single position vector. ```js displace(xPosition, yPosition, zPosition); displace(position); ``` -------------------------------- ### toSpherical() JavaScript Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/math/toSpherical.md Basic syntax for calling the `toSpherical()` function in JavaScript. ```js toSpherical(space); ``` -------------------------------- ### hsv2rgb() Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/hsv2rgb.md Detailed API documentation for the hsv2rgb function, including its parameters and their types. This function converts HSV color values to RGB, expecting input components normalized between 0.0 and 1.0. ```APIDOC hsv2rgb(inputColor): inputColor: Vec3 - input hue, saturation, color values from 0.0 to 1.0 ``` -------------------------------- ### Shader Park rotateX() JavaScript Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/rotateX.md Illustrates the basic JavaScript syntax for using the `rotateX()` function to apply rotation around the x-axis in Shader Park. ```javascript rotateX(amount); ``` -------------------------------- ### JavaScript Syntax for rotateY() Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/rotateY.md Shows the basic syntax for calling the rotateY function in JavaScript. ```js rotateY(amount); ``` -------------------------------- ### Shader Park: Composition API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for the 'shape' function used for defining the overall composition of a Shader Park sculpture. ```APIDOC shape() ``` -------------------------------- ### Shader Park: Material Properties API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions that define the visual material properties of objects, such as color, metallicness, shininess, and blending. ```APIDOC color() metal() shine() mixMat() hsv2rgb() rgb2hsv() occlusion() fresnel() ``` -------------------------------- ### Shader Park GLSL Core Functions: surfaceDistance and shade Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md Explains the purpose and usage of the `surfaceDistance` function for defining Signed Distance Fields (SDFs) and the `shade` function for coloring surfaces in Shader Park's GLSL editor. It notes the convention difference from 'map' or 'scene' functions. ```APIDOC surfaceDistance(point: vec3): float - Purpose: Computes the distance from a given point to the surface of the 3D object. - Note: In Shader Park, this function replaces the common 'map' or 'scene' functions for SDFs. - Returns: The signed distance to the nearest surface. shade(point: vec3, normal: vec3): vec4 - Purpose: Evaluates the color of the surface at the intersection point. - Parameters: - point: The intersection point on the surface. - normal: The surface normal at the intersection point, numerically computed using the tetrahedron technique. - Returns: The final color (vec4) of the surface. - Note: If a custom raymarcher is desired, set surfaceDistance to return 0.0 and implement everything within the shade function. ``` -------------------------------- ### mouseIntersection() Function Syntax (JavaScript) Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/input/mouseIntersection.md Basic syntax for calling the `mouseIntersection()` function in JavaScript. ```js mouseIntersection(); ``` -------------------------------- ### Shader Park torus() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/torus.md Defines the syntax for calling the `torus()` function in Shader Park, which draws a torus shape. It takes two parameters: `outerRingSize` and `innerRingSize`. ```js torus(outerRingSize, innerRingSize); ``` -------------------------------- ### Shader Park color() Function Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/color.md Provides the API documentation for the `color()` function in Shader Park, which applies a specified RGB color to subsequent objects. Parameters define the red, green, and blue components, each ranging from 0.0 to 1.0. ```JavaScript color(red, green, blue); ``` ```APIDOC color(red, green, blue): red: Float (value from 0.0 to 1.0) green: Float (value from 0.0 to 1.0) blue: Float (value from 0.0 to 1.0) ``` -------------------------------- ### GLSL specularLighting Function Signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/lighting/specularLighting.md Defines the signature for the `specularLighting` function, which calculates specular lighting based on the surface position, normal vector, light direction, and material shininess. ```glsl float specularLighting(vec3 p, vec3 normal, vec3 lightDirection, float shine) ``` -------------------------------- ### occlusion() Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/occlusion.md API documentation for the `occlusion()` function, used to approximate soft shadows in Shader Park. It takes a single float parameter to control the amount of occlusion. ```APIDOC occlusion(amount) Description: Approximates the soft shadows. Parameters: amount: Type: Float Description: Value from 0.0 to 1.0 ``` ```js occlusion(amount); ``` -------------------------------- ### mirrorX() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/mirrorX.md Mirrors all subsequent drawing operations along the x-axis. This function takes no arguments and modifies the rendering context. ```js mirrorX(); ``` -------------------------------- ### rgb2hsv() Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/rgb2hsv.md Detailed API documentation for the `rgb2hsv` function, including its syntax and parameter definitions. This function transforms a 3-component RGB color vector (normalized 0.0-1.0) into its HSV equivalent. ```APIDOC rgb2hsv(inputColor): inputColor: Vec3 - input red, green, and blue color values from 0.0 to 1.0 ``` ```js rgb2hsv(inputColor); ``` -------------------------------- ### lightDirection() Function Syntax and Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/lightDirection.md The `lightDirection()` function sets the direction of the built-in lighting in Shader Park. It can accept individual `x`, `y`, `z` float values or a single `Vec3` `position` vector. By default, the light points from the top down, equivalent to `lightDirection(0, 1, 0)`. ```js lightDirection(x, y, z); lightDirection(position); ``` ```APIDOC lightDirection(x, y, z) x: Float: value from 0.0 to 1.0. Defaults to 0 y: Float: value from 0.0 to 1.0. Defaults to 1 z: Float: value from 0.0 to 1.0. Defaults to 0 lightDirection(position) position: Vec3: defaults to vec3(0, 1, 0) ``` -------------------------------- ### Shader Park: Geometry Construction Modes API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions used to combine or modify existing geometric shapes in Shader Park. ```APIDOC union() difference() blend() intersect() mixGeo() ``` -------------------------------- ### setStepSize Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/global-settings/setStepSize.md Detailed API documentation for the `setStepSize` function, including its parameter, type, allowed range, and default value. This function is crucial for fine-tuning the balance between visual quality and performance in Shader Park's raymarching engine. ```APIDOC setStepSize(size) size: Float (range: 0.0 to 1.0, default: 0.85) - Controls the raymarching step size. ``` -------------------------------- ### boxFrame() Function Syntax and Parameters Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/boxFrame.md Draws a 3D box frame with specified dimensions and line thickness. This function is part of the Shader Park library. ```JavaScript boxFrame(size, thickness); ``` ```APIDOC boxFrame(size, thickness) size: Vector3 - size of the boxframe thickness: Float - thickness of the frame ``` -------------------------------- ### Shader Park: Coordinate Space Modifiers API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Reference for functions that manipulate the coordinate space of objects in Shader Park, including displacement, space setting, mirroring, and rotation. ```APIDOC displace() setSpace() mirrorX() mirrorY() mirrorZ() mirrorXYZ() mirrorN() rotateX() rotateY() rotateZ() reset() ``` -------------------------------- ### GLSL Built-in Data Types and Functions Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/tutorials/README.md This section outlines common built-in data types and mathematical functions available in GLSL (OpenGL Shading Language). These types and functions are optimized for GPU execution and are essential for writing efficient shaders. They include vector and matrix types, and various mathematical operations. ```APIDOC Built-in Types: vec2: 2-component vector vec3: 3-component vector vec4: 4-component vector mat2: 2x2 matrix mat3: 3x3 matrix mat4: 4x4 matrix Built-in Functions: float length(vec v): Returns the length of a vector. float distance(vec v1, vec v2): Returns the distance between two points. vec normalize(vec v): Returns a vector with the same direction but a length of 1. pow(x, y): Returns x raised to the power of y. exp(x): Returns the base-e exponential of x. sqrt(x): Returns the square root of x. abs(x): Returns the absolute value of x. Trigonometric functions: sin, cos, tan, atan, acos, asin ``` -------------------------------- ### Shader Park box() Function Overloads and API Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/geometries/box.md The `box()` function in Shader Park is fundamental for creating cubic shapes. It provides two convenient overloads: one that accepts explicit numerical values for `width`, `height`, and `depth` for precise control, and another that takes a single `Vec3` object, simplifying dimension specification when grouped. The API documentation below outlines the parameters for each overload. ```javascript box(width, height, depth); ``` ```javascript box(size); ``` ```APIDOC box(width: Number, height: Number, depth: Number) width: Number - width of the box height: Number - height of the box depth: Number - depth of the box box(size: Vec3) size: Vec3 - width, height and depth of the box ``` -------------------------------- ### GLSL softSquare Function Signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/math/softSquare.md Defines the `softSquare` function, which takes a float `x` and an integer `squareness` to blend between sine and square wave forms. ```GLSL float softSquare(float x, int squareness); ``` -------------------------------- ### GLSL Function Signature: rgb2hsv Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/color/rgb2hsv.md Signature for the `rgb2hsv` function, which takes a `vec3` representing an RGB color and returns a `vec3` representing the corresponding HSV color. The `in` keyword indicates that the parameter `c` is an input. ```GLSL vec3 rgb2hsv( in vec3 c ); ``` -------------------------------- ### Shader Park: Conditional Logic Limitation with Built-in Variables Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/README.md Illustrates a known limitation where branching statements (if/else) referencing built-in variables like 'time' or 'vec' types do not work as expected in Shader Park. ```JavaScript if(time > 100) { //do something } ``` -------------------------------- ### Shader Park rotateZ() Function Syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/rotateZ.md Basic syntax for calling the `rotateZ()` function in Shader Park to rotate the coordinate space around the Z-axis. ```js rotateZ(amount); ``` -------------------------------- ### getSpace() API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/input/getSpace.md Documents the `getSpace()` function, which retrieves the current coordinate space. This function is useful when combining operations and needing a reference to an unchanged coordinate space. When called inside `shape()`, it returns a new reference to the space at the current scope. ```APIDOC getSpace(); Returns: Vec3: The current coordinate space ``` -------------------------------- ### JavaScript intersect() function usage Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/intersect.md Basic syntax for calling the intersect function in Shader Park to display the intersection of geometries. ```js intersect(); ``` -------------------------------- ### GLSL noise function signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/noise/noise.md Defines the signature for the `noise` function, which takes a `vec3` position and returns a `vec3`. ```GLSL vec3 noise(vec3 pos); ``` -------------------------------- ### JavaScript Syntax for setSDF() Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/setSDF.md Illustrates the basic syntax for calling the `setSDF()` function in Shader Park, which is used to define the distance field for 3D geometry. The function expects a single float parameter. ```js setSDF(distance); ``` -------------------------------- ### GLSL `occlusion` Function Signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/lighting/occlusion.md This GLSL function signature defines the `occlusion` function used in Shader Park. It takes a 3D position vector `p` and a 3D normal vector `normal` as input, and returns a `float` value representing the approximated soft shadows. ```GLSL float occlusion(vec3 p, vec3 normal); ``` -------------------------------- ### Convert Spherical to Cartesian Coordinates (GLSL) Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/math/fromSpherical.md Converts from spherical to Cartesian coordinates. x, y, and z input coordinates correspond to radius, theta, and phi respectively. ```glsl vec3 fromSpherical(vec3 p); ``` -------------------------------- ### GLSL box Function Signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/geometries/box.md The `box` function in Shader Park takes a 3D point `p` and a 3D size vector `size` as input. It returns a float, commonly representing the signed distance from the point `p` to the surface of a box defined by `size`. ```GLSL float box(vec3 p, vec3 size); ``` -------------------------------- ### setSDF() Function API Reference Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/setSDF.md Detailed API documentation for the `setSDF()` function in Shader Park, outlining its parameters and their types. This function is crucial for directly setting the distance field value. ```APIDOC setSDF(distance) Parameters: distance: Float - The distance from the current position to the geometry's surface. ``` -------------------------------- ### GLSL Function: shell Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/operations/shell.md Removes the interior of a solid object, creating a hollow shell. Takes a distance field `d` and a `thickness` as input. ```glsl float shell(float d, float thickness); ``` -------------------------------- ### GLSL Distance Function for a Sphere Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/tutorials/README.md This GLSL function calculates the signed distance from a point 'p' to a sphere of radius 'r' centered at the origin. It leverages GLSL's built-in 'length' function for vector magnitude. This function is fundamental for rendering spheres using raymarching or sphere-tracing algorithms. ```GLSL float sphere(vec3 p, float r) { return length(p)-r; } ``` -------------------------------- ### JavaScript fresnel() function syntax Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/color/fresnel.md Defines the syntax for the `fresnel()` function in JavaScript. It takes a single `value` parameter, which is a Float representing the amount, to generate a radial gradient for edge glow effects. ```js fresnel(value); ``` -------------------------------- ### mouse GLSL Global Variable Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/README.md A global GLSL variable that provides access to the current mouse input state, typically representing its normalized 2D coordinates or a 3D ray origin/direction in the scene. ```glsl vec3 mouse; ``` -------------------------------- ### GLSL sphericalDistribution Function Signature Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/math/sphericalDistribution.md Defines the `sphericalDistribution` function, which takes a 3D point `p` and a float `n` representing the number of points. It returns a `vec4` where the `xyz` components are the nearest point's coordinates and the `w` component is the distance to it. ```glsl vec4 sphericalDistribution( vec3 p, float n ); ``` -------------------------------- ### Mirror Y-axis in Shader Park (JavaScript) Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/mirrorY.md Applies a mirror transformation to all subsequent operations along the y-axis. This function is part of the Shader Park library and takes no arguments. ```js mirrorY(); ``` -------------------------------- ### GLSL Function Signature for rot2 Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references/math/rot2.md This snippet provides the GLSL function signature for `rot2`, which takes a float `a` (angle) and returns a `mat2` (2x2 matrix) representing a 2D rotation. ```glsl mat2 rot2(float a); ``` -------------------------------- ### Mirror Z-axis operation in JavaScript Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/mirrorZ.md Applies a mirroring transformation along the Z-axis to subsequent operations in Shader Park. This function takes no arguments and is typically used within a drawing or transformation context. ```js mirrorZ(); ``` -------------------------------- ### Union Function Call Source: https://github.com/shader-park/shader-park-docs/blob/master/docs/references-js/operations/union.md Calls the `union()` function to add new geometry to the scene. This function is applied by default when new geometry is added. ```js union(); ```