VGens Overview:
Filter:
Scintillator/Guides (extension) | Quarks > Scintillator > Guides

VGens Overview
ExtensionExtension

A list of the available VGens within Scintillator.

Video Oscillators

There are only a few test oscillators implemented for now, with plans to add many more. One key conceptual difference between SuperCollider audio oscillators and Scintillator video oscillators to bear in mind is that video signals are constrained to values between [0, 1], unlike audio signals, which operate normally between [-1, 1].

VGenRatesDimensionsDescription
VSinOsc.fr(freq, phas, mul, add)frame, shape, pixel
inputoutput
1, 1, 1, 11
2, 2, 2, 22
3, 3, 3, 33
4, 4, 4, 44
Piecewise sinusodal oscillator, analogous to SinOsc
VSaw.fr(freq, phas, mul, add)frame, shape, pixel
inputoutput
1, 1, 1, 11
2, 2, 2, 22
3, 3, 3, 33
4, 4, 4, 44
Piecewise sawtooth oscillator, analogous to LFSaw

Image Sampling

VGens for reading from ScinImageBuffer objects.

VGenRatesDimensionsDescription
VSampler.pr(image, pos)frame, shape, pixel
inputoutput
image, 24
Samples the provided imageBuffer at pos and returns the 4D color signal as (red, green, blue, alpha)
VTexPos.fr()shape, pixel
inputoutput
-2
Texture Sampler position
VTextureSize.fr(image)frame, shape, pixel
inputoutput
-2
Returns the dimensions in pixels of the provided ScinImageBuffer. Roughly analogous to BufFrames.

Tween Sampling

The ScinTween class describes a series of simple curves which the server can populate into a table, and then sample with interpolation with VGens at runtime. Scintillator provides VTweenGen VGens for sampling the tween curves over time, and VTweenSampler VGens for time-invariant tween sampling.

VGenRatesDimensionsDescription
VTweenGen1.fr(tween, levelScale, levelBias, timeScale, timeBias)frame, shape, pixel
inputoutput
tween, 1, 1, 1, 11
Samples a 1-dimensional tween table over time.
VTweenGen2.fr(tween, levelScale, levelBias, timeScale, timeBias)frame, shape, pixel
inputoutput
tween, 1, 1, 1, 12
Samples a 2-dimensional tween table over time.
VTweenGen4.fr(tween, levelScale, levelBias, timeScale, timeBias)frame, shape, pixel
inputoutput
tween, 1, 1, 1, 14
Samples a 4-dimensional tween table over time.
VTweenSampler1.fr(tween, t)frame, shape, pixel
inputoutput
tween, 11
Samples a 1-dimensional tween table at any point.
VTweenSampler2.fr(tween, t)frame, shape, pixel
inputoutput
tween, 12
Samples a 2-dimensional tween table at any point.
VTweenSampler4.fr(tween, t)frame, shape, pixel
inputoutput
tween, 14
Samples a 4-dimensional tween table at any point.

Fragment Position

Scintillator offers a few different means to determine the position of the current fragment shader relative to the geometry being rendered, or the onscreen pixel dimensions. The VTexPos VGen is in the Image Sampling section.

VGenRatesDimensionsDescription
VNormPos.pr()shape, pixel
inputoutput
-2
Normalized fragment position
VTexPos.pr()shape, pixel
inputoutput
-2
Texture Sampler position
VFragCoord.pr()pixel
inputoutput
-2
Onscreen coordinates of current fragment in pixels

Vector Manipulation

These utility VGens allow the grouping of one-dimensional elements into vectors, access to individual elements within vectors, and lastly a convenience function to repeat (or splat) a single element across all elements within a vector.

Vector Building

Some VGens require inputs that are higher-dimensional vectors. To construct those inputs from single-dimensional components, Scintillator provides the VecN classes.

VGenRatesDimensionsDescription
VVec2.fr(x, y)frame, shape, pixel
inputoutput
1, 12
Construct a 2D vector from individual elements x and y
VVec3.fr(x, y, z)frame, shape, pixel
inputoutput
1, 1, 13
Construct a 3D vector from individual elements x and y
VVec4.fr(x, y, z, w)frame, shape, pixel
inputoutput
1, 1, 1, 14
Construct a 4D vector from individual elements x and y
VSplat2.fr(x)frame, shape, pixel
inputoutput
12
Construct a 2D vector from a single element copied into both
VSplat3.fr(x)frame, shape, pixel
inputoutput
13
Construct a 3D vector from a single element copied into both
VSplat4.fr(x)frame, shape, pixel
inputoutput
14
Construct a 4D vector from a single element copied into both

Element Access

To break out a single-dimensional signal from a higher-dimensional vector, use the VX and related classes. These follow the computer graphics naming conventions for elements within the vector, where the names x, y, z, w are used to indicate the first through fourth element respectively.

VGenRatesDimensionsDescription
VX.fr(v)frame, shape, pixel
inputoutput
11
21
31
41
Return the first element in the vector.
VY.fr(v)frame, shape, pixel
inputoutput
21
31
41
Return the second element in the vector.
VZ.fr(v)frame, shape, pixel
inputoutput
31
41
Return the third element in the vector.
VW.fr(v)frame, shape, pixel
inputoutput
41
Return the fourth element in the vector.

Color Output

Note that any vec4 output is considered valid ScinthDef output, but these can help with code clarity or with grouping of single-channel inputs into a vec4, sometimes with that fourth alpha component hard-coded to 1.0. In the future the server may perform opacity calling, so knowing an output is entirely opaque will allow VRGBOut and VBWOut to take advantage of that culling automatically.

VGenRatesDimensionsDescription
VRGBOut.pr(red, green, blue)pixel
inputoutput
1, 1, 14
Convenience object for color output at full opacity
VRGBAOut.pr(red, green, blue, alpha)pixel
inputoutput
1, 1, 1, 14
Convenience object for color output with alpha channel
VBWOut.pr(value)pixel
inputoutput
14
Convenience object for black and white output at full opacity

Mathematical Operations

Scintillator offers per-element (or piecewise) operations as well as some more traditional vector mathematical operations such as dot and cross products. Many unary and binary operations are offerred with the same names as their analog counterparts,

Vector Operations

VGenRatesDimensionsDescription
VClamp.pr(v, min, max)frame, shape, pixel
inputoutput
1, 1, 11
2, 2, 22
3, 3, 33
4, 4, 44
Video equivalent of Clip UGen, piecewise bounds input v between [min, max]
VLength.pr(v)frame, shape, pixel
inputoutput
11
21
31
41
Returns the length of the vector x, or the square root of the sum of the squares
VDistance.pr(u, v)frame, shape, pixel
1, 11
2, 21
3, 31
4, 41
Computes the distance between u and v, which is the length of the vector v - u
VStep.pr(step, x)frame, shape, pixel
inputoutput
1, 11
2, 22
3, 33
4, 44
Just like the binary operator thresh, returns 0 when x < step, otherwise x
VMix.pr(v, u, a)frame, shape, pixel
inputoutput
1, 1, 11
2, 2, 12
2, 2, 22
3, 3, 13
3, 3, 33
4, 4, 14
4, 4, 44
Similar to the binary operator blend, returns a linear mix of v, u with a between [0, 1]. Supports piecewise blend or a single blend argument to apply to all components
VDot.pr(u, v)frame, shape, pixel
inputoutput
1, 11
2, 21
3, 31
4, 41
Returns the dot product between u and v, or the sum of the product of each component in the vector
VCross.pr(u, v)frame, shape, pixel
inputoutput
3, 33
Returns the cross product of u and v
VNorm.pr(v)frame, shape, pixel
inputoutput
1, 11
2, 22
3, 33
4, 44
Returns a normalized vector parallel to v with length 1

Built-In Unary Operations

The SuperCollider UGens support a broad variety of unary, binary, and n-ary mathematical operations. These are typically expressed as operators within the SynthDef flow, and are transformed by the SynthDef programming into one of the subclasss of BasicOpUGen before being sent to the server. Scintillator implements parallel classes for unary and binary operations, with the BasicOpVGen as the base class and UnaryOpVGen and BinaryOpVGen derived classes handling a subset of the operators handled by the UGen programming.

For documentation of these operators in base SuperCollider see the Operators overview or the SimpleNumber class documentation.

The following tables detail the current supported operations along with the ones that are not yet supported, the name of the VGen sent to the server to realize the operation, a brief explanation of their function and conceptual mathematical code. Since all numbers within a Scintillator ScinthDef must be floating-point, several of the integer operations like bit manipulation are marked as not applicable. If support is planned, but not yet implemented, the function is marked as not yet implemented.

For higher-dimensional signals all operations happen piecewise, meaning the operator is applied to each component of the signal independently. For example if b = a.neg and both a and b are VVec4 objects then:

NOTE: All unary operations are supported at all rates, support inputs in 1-4 dimensions, and produce outputs of the same dimension.
OperatorVGenDescriptionconceptual sclang code
negVNegUnary negationx = -1 * x
reciprocalVReciprocalReciprocal divisionx = 1 / x
bitNotnot applicableBitwise inversionn/a
absVAbsAbsolute valueif (x < 0, { x.neg }, { x })
asFloatnot applicableConvert to floatn/a
asIntegernot applicableConvert to integern/a
ceilVCeilNearest integer greater than xif ((x - x.asInteger) > 0, { (x.asInteger) + 1.0 }, { x })
floorVFloorNearest integer lesser than xx.asInteger.asFloat
fracVFractFractional remainder of xx - x.asInteger
signVSignSign, either -1, 0, or +1 matching sign of xcase { x < 0 } { -1.0 } { x == 0 } { 0.0 } { 1.0 }
squaredconverted to x * xSquare of a numberx * x
cubedconverted to x * x * xCube of a numberx * x * x
sqrtVSqrtSquare rootx.sqrt
expVExpNatural exponentiatione ** x
midicpsnot yet implementedMIDI note to cycles per secondn/a
cpsmidinot yet implementedCycles per second to MIDI noten/a
midirationot yet implementedConvert an interval in MIDI notes to a frequency ration/a
ratiomidinot yet implementedConvert a frequency ratio to an interval in MIDI notesn/a
ampdbnot yet implementedConvert decibels to linear amplituden/a
dbampnot yet implementedConvert linear amplitude to decibelsn/a
octcpsnot yet implementedConvert decimal octaves to cycles per secondn/a
cpsoctnot yet implementedConvert cycles per second to decimal octavesn/a
logVLogNatural logarithmx.log
log2VLog2Base 2 logarithmx.log2
log10not yet implementedBase 10 logarithmn/a
sinVSinSinex.sin
cosVCosCosinex.cos
tanVTanTangentx.tan
asinVASinArcsinex.asin
acosVACosArccosinex.acos
atanVATanArctangentx.atan
randnot yet implementedReturns an evenly distributed random value between zero and xx.rand
rand2not yet implementedReturns an evenly distributed random value beteen -x and +xx.rand2
linrandnot yet implementedReturns a linearly distributed random value between x and zerox.linrand
bilinrandnot yet implementedReturns a linearly distributed random value between -x and +xx.bilinrand
sum3randnot yet implementedReturns a value from an approximation of a Gaussian random distribution between x and zerox.sum3rand
distortnot yet implementedNonlinear distortion of xn/a
softclipnot yet implementedDistortion with a linear region from 0.25 to 0.75n/a
coinnot yet implementedReturns one or zero with the probability given by the argumentx.coin
evennot applicableTrue if dividable by two with no remaindern/a
oddnot applicableTrue if dividable by two with a remainder of 1n/a
rectWindownot yet implementedA value for a rectangular window function between 0 and 1n/a
hanWindownot yet implementedA value for a Hanning window function between 0 and 1n/a
welWindownot yet implementedA value for a Welsh window function between 0 and 1n/a
triWindownot yet implementedA value for a triangle window function between 0 and 1n/a
scurvenot yet implementedMap x on to an S-curven/a
rampnot yet implementedMap receiver onto a ramp starting at 0n/a
isPositivenot applicableTrue if x is >= 0n/a
isNegativenot applicableTrue if x is < 0n/a
isStrictlyPositivenot applicableTrue if x is > 0n/a
rhonot yet implementedThe polar radius of xn/a
thetanot yet implementedThe polar angle of xn/a
refunknownTo be researched what this operator does??

Built-In Binary Operations

Binary operations also happen piecewise, meaning that the binary operator is applied to each individual component separately. Conceptually if c = a * b and both a and b are VVec4s then:

OperatorVGenDescriptionconceptual sclang code
rotateunknownTo be researched what this operator does??
distunknownTo be researched what this opreator does??
+VAddAdditiona + b
-VSubSubtractiona - b
*VMulMultiplicationa * b
/VDivDivisiona / b
divVDivDivision, TODO: validate if this is really divisiona / b
modVModFloating-point moduloa % b
powVPowExponentiationa ** b
minVMinPiecewise minimumif (a < b, { a }, { b });
maxVMaxPiecewise maximumif (a > b, { a }, { b });
<not applicableTrue if a < bn/a
<=not applicableTrue if a <= bn/a
>not applicableTrue if a > bn/a
>=not applicableTrue if a >= bn/a
bitAndnot applicableBitwise logical ANDn/a
bitOrnot applicableBitwise logical ORn/a
bitXornot applicableBitwise logical XORn/a
hammingDistancenot applicableCount of bits that are differentn/a
lcmnot yet implementedLeast common multiplen/a
gcdnot yet implementedGreates common divisorn/a
roundnot yet implementedRound to a multiple of a numbern/a
roundUpnot yet implementedRound up to a multiple of a numbern/a
truncnot yet implementedTruncate to a muliple of a numbern/a
atan2VATan2Arctangent of a / b(a / b).atan
hypotnot yet implementedSquare root of the sum of the squaresn/a
hypotApxunknownTo be researched what this operator does??
leftShiftnot applicableShift bits to the leftn/a
rightShiftnot applicableShift bits to the rightn/a
unsignedRightShiftnot applicableShift bits to the right without preserving sign bitn/a
ring1not yet implementedRing modulation plus first source(a * b) + a
ring2not yet implementedRing modulation plus both sources(a * b) + a + b
ring3not yet implementedRing modulation varianta * a * b
ring4not yet implementedRing modulation variant(a * a * b) - (a * b * b)
difsqrnot yet implementedDifference of squares(a * a) - (b * b)
sumsqrnot yet implementedSum of the squares(a**2) + (b**2)
sqrsumnot yet implementedSquare of the sum(a + b)**2
absdifnot yet implementedAbsolute value of the difference(a - b).abs
threshnot yet implementedThresholdingif (a < b, { 0 }, { a });
amclipnot yet implementedTwo quadrant multiplyif (b <= 0, { 0 }, { a * b });
scalenegnot yet implementedScale negative part of inputif (a < 0, { a * b }, { a });
clip2not yet implementedClip a to +/-bif (a.abs < b, { b * a.sign }, { a });
fold2not yet implementedBilateral foldingn/a
wrap2not yet implementedBilateral wrappingn/a
excesssnot yet implementedResidual clippingn/a
firstArgunknownTo be researched what this operator does??
rrandnot yet implementedGenerate a uniformly distributed pseudorandom number in [a, b]n/a
exprandnot yet implementedGenerate an exponentially distributed pseudorandom number in [a, b]n/a
@unknownTo be researched what this operator does??
||not applicableBoolean logical ORn/a
&&not applicableBoolean logical ANDn/a
xornot applicableBoolean logical XORn/a
nandnot applicableBoolean logical NANDn/a