Vuo  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Typedefs

Description

A graphics shader program, specifying how to render a 3D object.

A VuoShader can contain up to 3 separate GL Program Objects, each of which processes a different type of input primitive (points, lines, triangles).

Each GL Program Object must contain a vertex shader, and can optionally contain a geometry and/or fragment shader.

If no fragment shader is present, the program object is assumed to be used for Transform Feedback (see VuoSceneObjectRenderer).

The struct is typedef'd to a pointer so that VuoShaders are reference-counted, enabling Vuo to automatically delete the GL Program Objects when the last reference is released.

Usage

To create a shader that supports rendering points, lines, and triangles to a framebuffer:

VuoShader shader = VuoShader_make("Color Shader (Unlit)");
VuoShader_addSource(shader, VuoMesh_Points, vertexShader1, geometryShader1, fragmentShader1);
VuoShader_addSource(shader, VuoMesh_IndividualLines, vertexShader2, geometryShader2, fragmentShader2);
VuoShader_addSource(shader, VuoMesh_IndividualTriangles, vertexShader3, NULL, fragmentShader3);
VuoShader_setUniform_VuoColor(shader, "color", color);

To render using that shader:

GLint positionAttribute, normalAttribute, tangentAttribute, bitangentAttribute, textureCoordinateAttribute;
VuoShader_getAttributeLocations(shader, elementAssemblyMethod, glContext, &positionAttribute, &normalAttribute, &tangentAttribute, &bitangentAttribute, &textureCoordinateAttribute);
// [...] enable vertex attribute arrays
VuoShader_activate(shader, elementAssemblyMethod, glContext);
// [...] glDrawArrays() or glDrawElements()
VuoShader_deactivate(shader, elementAssemblyMethod, glContext);
// [...] disable vertex attribute arrays

Classes

struct  VuoSubshader
 References to shader source code and shader code uploaded to the GPU. More...
 
struct  VuoShaderUniform
 Holds values to eventually be assigned to a GL Program Object's uniforms. More...
 
union  VuoShaderUniform.value
 
struct  _VuoShader
 A graphics shader program, specifying how to render a 3D object. More...
 

Typedefs

typedef struct _VuoShaderVuoShader
 A graphics shader program, specifying how to render a 3D object.
 

Creating shaders from GLSL source code

VuoShader VuoShader_make (const char *name)
 Creates a shader object, which contains multiple GL Program Objects.
 
void VuoShader_addSource (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const char *vertexShaderSource, const char *geometryShaderSource, const char *fragmentShaderSource)
 Associates GLSL shader source code with the specified inputPrimitiveMode of the specified shader.
 
void VuoShader_setExpectedOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const unsigned int expectedOutputPrimitiveCount)
 Specifies the number of primitives the geometry shader is expected to produce per invocation.
 
void VuoShader_setMayChangeOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const bool mayChangeOutputPrimitiveCount)
 Specifies whether the geometry shader may dynamically choose to skip outputting some primitives or output additional primitives.
 
#define VUOSHADER_GLSL_SOURCE(version, source)   "#version " #version "\n" #source
 A macro to facilitate defining a GLSL shader in a C source file.
 

Creating standard shaders

VuoShader VuoShader_makeDefaultShader (void)
 Returns a shared instance of the default (unlit checkerboard) shader.
 
VuoShader VuoShader_makeUnlitImageShader (VuoImage image, VuoReal alpha)
 Returns a shader that renders objects with an image (ignoring lighting).
 
VuoShader VuoShader_makeUnlitAlphaPassthruImageShader (VuoImage image, bool flipped)
 Returns a shader that renders objects with an image (ignoring lighting).
 
VuoShader VuoShader_makeGlTextureRectangleShader (VuoImage image, VuoReal alpha)
 Returns a shader that renders objects with an image (ignoring lighting).
 
VuoShader VuoShader_makeGlTextureRectangleAlphaPassthruShader (VuoImage image, bool flipped)
 Returns a shader that renders objects with an image (ignoring lighting).
 
VuoShader VuoShader_makeUnlitColorShader (VuoColor color)
 Returns a shader that renders a solid color.
 
VuoShader VuoShader_makeUnlitCircleShader (VuoColor color, VuoReal sharpness)
 Returns a shader that renders a solid color circle.
 
VuoShader VuoShader_makeUnlitRoundedRectangleShader (VuoColor color, VuoReal sharpness, VuoReal roundness, VuoReal aspect)
 Returns a shader that renders a solid color rounded rectangle.
 
VuoShader VuoShader_makeLitColorShader (VuoColor diffuseColor, VuoColor highlightColor, VuoReal shininess)
 Returns a shader that renders a color with lighting.
 
VuoShader VuoShader_makeLitImageShader (VuoImage image, VuoReal alpha, VuoColor highlightColor, VuoReal shininess)
 Returns a shader that renders an image with lighting.
 
VuoShader VuoShader_makeLitImageDetailsShader (VuoImage image, VuoReal alpha, VuoImage specularImage, VuoImage normalImage)
 Returns a shader that renders an image with lighting and surface details.
 
VuoShader VuoShader_makeLinearGradientShader (void)
 Returns a linear gradient shader.
 
void VuoShader_setLinearGradientShaderValues (VuoShader shader, VuoList_VuoColor colors, VuoPoint2d start, VuoPoint2d end, VuoReal aspect, VuoReal noiseAmount)
 Sets parameters for the linear gradient shader using the provided colors and start and end coordinates.
 
VuoShader VuoShader_makeRadialGradientShader (void)
 Returns a radial gradient shader.
 
void VuoShader_setRadialGradientShaderValues (VuoShader shader, VuoList_VuoColor colors, VuoPoint2d center, VuoReal radius, VuoReal width, VuoReal height, VuoReal noiseAmount)
 Sets parameters for the radial gradient shader using the provided colors, center point, and radius.
 
VuoShader VuoShader_makeFrostedGlassShader (void)
 Returns a frosted glass shader.
 
void VuoShader_setFrostedGlassShaderValues (VuoShader shader, VuoColor color, VuoReal brightness, VuoReal noiseTime, VuoReal noiseAmount, VuoReal noiseScale, VuoReal chromaticAberration, VuoInteger levels, VuoReal roughness, VuoReal spacing, VuoInteger iterations)
 Sets parameters for the frosted glass shader.
 

Using shaders

bool VuoShader_isTransformFeedback (VuoShader shader)
 Returns true if each of shader's defined inputPrimitiveModes has a vertex shader (and optionally a geometry shader) but lacks a fragment shader.
 
unsigned int VuoShader_getExpectedOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode)
 Returns the number of primitives the geometry shader is expected to produce per invocation.
 
bool VuoShader_getMayChangeOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode)
 Returns true if the geometry shader may not output the expected primitive count.
 
bool VuoShader_getAttributeLocations (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, int *positionLocation, int *normalLocation, int *tangentLocation, int *bitangentLocation, int *textureCoordinateLocation)
 Outputs the shader program's vertex attribute locations (the same values as glGetAttribLocation()).
 
bool VuoShader_activate (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, VuoGlProgram *outputProgram)
 Activates the shader program (glUseProgram()) on the specified glContext, binds the shader's images to texture units, and uploads its unforms, so that the shader is ready for use in rendering.
 
void VuoShader_deactivate (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext)
 Unbinds the shader's images from their texture units.
 
void VuoShader_resetContext (VuoGlContext glContext)
 Disuses whatever shader (if any) is currently active on glContext.
 
void VuoShader_setUniform_VuoImage (VuoShader shader, const char *uniformIdentifier, const VuoImage image)
 Sets a VuoImage input value on the specified shader.
 
void VuoShader_setUniform_VuoBoolean (VuoShader shader, const char *uniformIdentifier, const VuoBoolean boolean)
 Sets a bool uniform value on the specified shader.
 
void VuoShader_setUniform_VuoInteger (VuoShader shader, const char *uniformIdentifier, const VuoInteger integer)
 Sets an int uniform value on the specified shader.
 
void VuoShader_setUniform_VuoReal (VuoShader shader, const char *uniformIdentifier, const VuoReal real)
 Sets a float uniform value on the specified shader.
 
void VuoShader_setUniform_VuoPoint2d (VuoShader shader, const char *uniformIdentifier, const VuoPoint2d point2d)
 Sets a vec2 uniform value on the specified shader.
 
void VuoShader_setUniform_VuoPoint3d (VuoShader shader, const char *uniformIdentifier, const VuoPoint3d point3d)
 Sets a vec3 uniform value on the specified shader.
 
void VuoShader_setUniform_VuoPoint4d (VuoShader shader, const char *uniformIdentifier, const VuoPoint4d point4d)
 Sets a vec4 uniform value on the specified shader.
 
void VuoShader_setUniform_VuoColor (VuoShader shader, const char *uniformIdentifier, const VuoColor color)
 Sets a color uniform value on the specified shader accepting a VuoColor.
 
VuoShader VuoShader_make_VuoColor (VuoColor color)
 Creates an unlit color shader object.
 
VuoShader VuoShader_make_VuoShader (VuoShader shader)
 Returns the passed shader (does not make a copy).
 
VuoShader VuoShader_make_VuoImage (VuoImage image)
 Creates an unlit image shader.
 
VuoImage VuoShader_getUniform_VuoImage (VuoShader shader, const char *uniformIdentifier)
 Returns the VuoImage for the specified uniformIdentifier, or NULL if none matches.
 
VuoPoint2d VuoShader_samplerCoordinatesFromVuoCoordinates (VuoPoint2d vuoCoordinates, VuoImage image)
 Converts the provided vuoCoordinates into GLSL Sampler Coordinates relative to the provided image.
 
VuoReal VuoShader_samplerSizeFromVuoSize (VuoReal vuoSize)
 Converts an x-axis distance in Vuo Coordinates into GLSL Sampler Coordinates.
 

Summary, serialization, and reference counting

char * VuoShader_getSummary (const VuoShader value)
 Returns a summary of the shader: the text description provided to VuoShader_make.
 
VuoShader VuoShader_makeFromJson (struct json_object *js)
 Decodes the JSON object js, expected to contain a 64-bit integer (memory address or 0), to create a new VuoShader.
 
struct json_objectVuoShader_getJson (const VuoShader value)
 Encodes value as a JSON object.
 
struct json_objectVuoShader_getInterprocessJson (const VuoShader value)
 Calls VuoShader_getJson().
 
VuoShader VuoShader_makeFromString (const char *str)
 Automatically generated function.
 
char * VuoShader_getString (const VuoShader value)
 Automatically generated function.
 
void VuoShader_retain (VuoShader value)
 Automatically generated function.
 
void VuoShader_release (VuoShader value)
 Automatically generated function.
 

Class Documentation

struct VuoSubshader
Class Members
unsigned int expectedOutputPrimitiveCount
VuoText fragmentSource
VuoText geometrySource
unsigned int glFragmentShaderName
unsigned int glGeometryShaderName
unsigned int glVertexShaderName
bool mayChangeOutputPrimitiveCount
VuoGlProgram program
VuoText vertexSource
struct VuoShaderUniform
Class Members
VuoText name
VuoText type
union VuoShaderUniform value
union VuoShaderUniform.value
Class Members
VuoBoolean boolean
VuoColor color
VuoImage image
VuoInteger integer
VuoPoint2d point2d
VuoPoint3d point3d
VuoPoint4d point4d
VuoReal real
struct _VuoShader
Class Members
VuoImage colorBuffer The renderbuffer color texture captured for this shader (if any).
VuoImage depthBuffer The renderbuffer depth texture captured for this shader (if any).
bool isTransparent Is this shader meant to be a transparent overlay? If true, VuoSceneRenderer disables backface culling and depth buffer writing while rendering with this shader. In the fragment shader, use gl_FrontFacing to discard backfaces or treat them differently, if desired.
VuoSubshader lineProgram
void * lock dispatch_semaphore_t to serialize operations that modify the state of this GL program object.
VuoText name Text describing the shader, displayed in port popovers.
float objectScale Typically 1. If the shader draws an object, this specifies how large the object is relative to the quad onto which it's drawn (e.g., VuoShader_makeUnlitCircleShader() is 0.5 since the circle it draws is half the size of the quad).
VuoSubshader pointProgram
VuoSubshader triangleProgram
VuoShaderUniform * uniforms
unsigned int uniformsCount
bool useAlphaAsCoverage When enabled, the fragment shader's output alpha value is converted into a percentage of sub-pixel samples to cover with the shader's output color.

Since this also affects the depth buffer, it provides a cheap form of order-independent transparency ("cheap" because it results in only a few discrete levels of transparency: 3 levels for 2x multisampling, 5 for 4x, and 9 for 8x, and results in "screen door" dithering artifacts).

This is only effective when multisampling is enabled (

See Also
VuoSceneRenderer_renderToImage).

Macro Definition Documentation

#define VUOSHADER_GLSL_SOURCE (   version,
  source 
)    "#version " #version "\n" #source

A macro to facilitate defining a GLSL shader in a C source file.

Typedef Documentation

typedef struct _VuoShader * VuoShader

A graphics shader program, specifying how to render a 3D object.

Function Documentation

bool VuoShader_activate ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode,
VuoGlContext  glContext,
VuoGlProgram outputProgram 
)

Activates the shader program (glUseProgram()) on the specified glContext, binds the shader's images to texture units, and uploads its unforms, so that the shader is ready for use in rendering.

Parameters
shaderThe shader to activate.
inputPrimitiveModeThe shader program mode to activate.
glContextThe OpenGL context on which to activate the shader program.
outputProgramThe OpenGL program name and metadata.
Returns
True if the shader is ready to use, or false if:
  • the shader is NULL
  • or inputPrimitiveMode is invalid
  • or if there is no shader for this inputPrimitiveMode

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Todo:
support multisampled framebuffers (like the color image case above)
void VuoShader_addSource ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode,
const char *  vertexShaderSource,
const char *  geometryShaderSource,
const char *  fragmentShaderSource 
)

Associates GLSL shader source code with the specified inputPrimitiveMode of the specified shader.

(The compile and link steps are deferred until the shader is actually used.)

May be called multiple times, to enable this shader to support multiple inputPrimitiveModes.

Call before using VuoShader_getAttributeLocations, VuoShader_activate, and VuoShader_deactivate.

Parameters
shaderThe shader to modify.
inputPrimitiveModeThe type of input primitives this shader program will process. Should be VuoMesh_IndividualTriangles, VuoMesh_IndividualLines, or VuoMesh_Points.
vertexShaderSourceGLSL vertex shader source code. If NULL, a default vertex shader is used (it passes texture coordinates through, and projects the vertex).
geometryShaderSourceGLSL geometry shader source code. Optional (may be NULL), in which case the output of the vertex shader is passed through to the fragment shader.
fragmentShaderSourceGLSL fragment shader source code. Optional (may be NULL), in which case the shader is assumed to transform primitives into other primitives (rather than pixels), i.e., transform feedback.
See Also
VUOSHADER_GLSL_SOURCE

VuoSceneRenderer renders a VuoSceneObject into an image or window, and automatically provides several uniform values and vertex attributes to shaders. A few are required; the rest are optional.

uniform mat4 projectionMatrix;  // required
uniform bool useFisheyeProjection;  // When true, projectionMatrix is calculated assuming that the vertex shader will perform fisheye warping.  See `VuoGlslProjection.glsl`.

uniform mat4 modelviewMatrix;   // required

uniform mat4 cameraMatrixInverse;   // Inverse of the matrix's modelviewMatrix.  Apply this to worldspace coordinates to transform the scene such that the camera is at the origin.
uniform vec3 cameraPosition;

uniform float aspectRatio;  // Viewport aspect ratio.
uniform vec2 viewportSize;  // Viewport size in pixels.
uniform sampler2D colorBuffer;  // A color image of what's been rendered so far (just before executing this shader).
uniform sampler2D depthBuffer;  // A depth image of what's been rendered so far (just before executing this shader).

float primitiveSize;

uniform vec4 ambientColor;
uniform float ambientBrightness;

struct PointLight
{
    vec4 color;
    float brightness;
    vec3 position;
    float range;
    float sharpness;
};
uniform PointLight pointLights[16];
uniform int pointLightCount;

struct DirectionalLight
{
    vec4 color;
    float brightness;
    vec3 position;
    vec3 direction;
    float cone;
    float range;
    float sharpness;
};
uniform DirectionalLight directionalLights[16];
uniform int directionalLightCount;

attribute vec4 position;  // required
attribute vec4 normal;
attribute vec4 tangent;
attribute vec4 bitangent;
attribute vec4 textureCoordinate;
uniform bool hasTextureCoordinates;

VuoSceneObjectRenderer renders a VuoSceneObject into a VuoSceneObject, and automatically provides several uniform values and vertex attributes to shaders:

uniform mat4 modelviewMatrix;
uniform mat4 modelviewMatrixInverse;
attribute vec4 position;
attribute vec4 normal;
attribute vec4 tangent;
attribute vec4 bitangent;
attribute vec4 textureCoordinate;

And it expects as output:

varying vec4 outPosition;
varying vec4 outNormal;
varying vec4 outTangent;
varying vec4 outBitangent;
varying vec4 outTextureCoordinate;

This function may be called from any thread.

void VuoShader_deactivate ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode,
VuoGlContext  glContext 
)

Unbinds the shader's images from their texture units.

The shader program remains in use on glContext (in case it's needed again soon). To disuse the shader, see

See Also
VuoShader_resetContext.
Parameters
shaderThe shader to deactivate.
inputPrimitiveModeThe shader program mode to deactivate.
glContextThe OpenGL context on which to deactivate the shader program.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

bool VuoShader_getAttributeLocations ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode,
VuoGlContext  glContext,
int *  positionLocation,
int *  normalLocation,
int *  tangentLocation,
int *  bitangentLocation,
int *  textureCoordinateLocation 
)

Outputs the shader program's vertex attribute locations (the same values as glGetAttribLocation()).

If necessary, this function also compiles, links, and uploads the program.

Parameters
shaderThe shader to query.
inputPrimitiveModeThe shader program mode to query.
glContextAn OpenGL context to use.
[out]positionLocationOutputs the shader program's vertex position attribute location. Pass NULL if you don't care.
[out]normalLocationOutputs the shader program's vertex normal attribute location (or -1 if this shader program doesn't have one). Pass NULL if you don't care.
[out]tangentLocationOutputs the shader program's vertex tangent attribute location (or -1 if this shader program doesn't have one). Pass NULL if you don't care.
[out]bitangentLocationOutputs the shader program's vertex bitangent attribute location (or -1 if this shader program doesn't have one). Pass NULL if you don't care.
[out]textureCoordinateLocationOutputs the shader program's vertex texture coordinate attribute location (or -1 if this shader program doesn't have one). Pass NULL if you don't care.
Returns
false if the shader is NULL, or if it doesn't support the specified primitiveMode.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Todo:
cache values for each program?
unsigned int VuoShader_getExpectedOutputPrimitiveCount ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode 
)

Returns the number of primitives the geometry shader is expected to produce per invocation.

Parameters
shaderThe shader to query.
inputPrimitiveModeThe shader program mode to query.

This function may be called from any thread.

struct json_object* VuoShader_getInterprocessJson ( const VuoShader  value)
read

Calls VuoShader_getJson().

Interprocess support is not yet implemented.

This function may be called from any thread.

struct json_object* VuoShader_getJson ( const VuoShader  value)
read

Encodes value as a JSON object.

Serializes the pointer to the VuoShader object, since we need to preserve its reference count.

This function may be called from any thread.

bool VuoShader_getMayChangeOutputPrimitiveCount ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode 
)

Returns true if the geometry shader may not output the expected primitive count.

Parameters
shaderThe shader to query.
inputPrimitiveModeThe shader program mode to query.

This function may be called from any thread.

char* VuoShader_getString ( const VuoShader  value)

Automatically generated function.

char* VuoShader_getSummary ( const VuoShader  value)

Returns a summary of the shader: the text description provided to VuoShader_make.

This function may be called from any thread.

VuoImage VuoShader_getUniform_VuoImage ( VuoShader  shader,
const char *  uniformIdentifier 
)

Returns the VuoImage for the specified uniformIdentifier, or NULL if none matches.

bool VuoShader_isTransformFeedback ( VuoShader  shader)

Returns true if each of shader's defined inputPrimitiveModes has a vertex shader (and optionally a geometry shader) but lacks a fragment shader.

This function may be called from any thread.

VuoShader VuoShader_make ( const char *  name)

Creates a shader object, which contains multiple GL Program Objects.

Before using this shader, call VuoShader_addSource at least once.

Parameters
nameText describing the shader, displayed in port popovers. Use title case (e.g., Color Shader (Lit), Crop Image Shader, Threshold Shader (Luminance)). The value is copied, so you can free it after this function returns.

This function may be called from any thread.

VuoShader VuoShader_make_VuoColor ( VuoColor  color)

Creates an unlit color shader object.

VuoShader VuoShader_make_VuoImage ( VuoImage  image)

Creates an unlit image shader.

VuoShader VuoShader_make_VuoShader ( VuoShader  shader)

Returns the passed shader (does not make a copy).

VuoShader VuoShader_makeDefaultShader ( void  )

Returns a shared instance of the default (unlit checkerboard) shader.

It's a gradient checkerboard (white in the top-left corner), so you can see the object and get a feel for its texture coordinates.

This function may be called from any thread.

VuoShader VuoShader_makeFromJson ( json_object js)

Decodes the JSON object js, expected to contain a 64-bit integer (memory address or 0), to create a new VuoShader.

This function may be called from any thread.

VuoShader VuoShader_makeFromString ( const char *  str)

Automatically generated function.

VuoShader VuoShader_makeFrostedGlassShader ( void  )

Returns a frosted glass shader.

VuoShader VuoShader_makeGlTextureRectangleAlphaPassthruShader ( VuoImage  image,
bool  flipped 
)

Returns a shader that renders objects with an image (ignoring lighting).

This shader now handles alpha the same way VuoShader_makeUnlitImageShader does, so the only difference is that this shader also provides flipping.

image must be GL_TEXTURE_RECTANGLE_ARB.

This function may be called from any thread.

VuoShader VuoShader_makeGlTextureRectangleShader ( VuoImage  image,
VuoReal  alpha 
)

Returns a shader that renders objects with an image (ignoring lighting).

image must be GL_TEXTURE_RECTANGLE_ARB.

This function may be called from any thread.

VuoShader VuoShader_makeLinearGradientShader ( void  )

Returns a linear gradient shader.

This function may be called from any thread.

VuoShader VuoShader_makeLitColorShader ( VuoColor  diffuseColor,
VuoColor  highlightColor,
VuoReal  shininess 
)

Returns a shader that renders a color with lighting.

Parameters
diffuseColorThe primary material color.
highlightColorThe color of shiny specular highlights. Alpha controls the intensity of the highlights.
shininessA number representing how shiny the material is. 0 = dull; 1 = shiny; numbers in between represent varying amounts of shininess.

This function may be called from any thread.

VuoShader VuoShader_makeLitImageDetailsShader ( VuoImage  image,
VuoReal  alpha,
VuoImage  specularImage,
VuoImage  normalImage 
)

Returns a shader that renders an image with lighting and surface details.

Parameters
imageThe image which provides the diffuse / primary material color.
alphaThe opacity of the image (0 to 1).
specularImageAn image that specifies the specular color (RGB) and shininess (A).
normalImageAn image that specifies the surface details. The red and green channels respectively define the normal direction along the tangent and bitangent axes (0 = negative; 0.5 = straight; 1 = positive). The blue channel defines the height along the normal axis (0 = low; 1 = high).

This function may be called from any thread.

VuoShader VuoShader_makeLitImageShader ( VuoImage  image,
VuoReal  alpha,
VuoColor  highlightColor,
VuoReal  shininess 
)

Returns a shader that renders an image with lighting.

Parameters
imageThe image which provides the diffuse / primary material color.
alphaThe opacity of the image (0 to 1).
highlightColorThe color of shiny specular highlights. Alpha controls the intensity of the highlights.
shininessA number representing how shiny the material is. 0 = dull; 1 = shiny; numbers in between represent varying amounts of shininess.

This function may be called from any thread.

VuoShader VuoShader_makeRadialGradientShader ( void  )

Returns a radial gradient shader.

This function may be called from any thread.

VuoShader VuoShader_makeUnlitAlphaPassthruImageShader ( VuoImage  image,
bool  flipped 
)

Returns a shader that renders objects with an image (ignoring lighting).

This shader now handles alpha the same way VuoShader_makeUnlitImageShader does, so the only difference is that this shader also provides flipping.

image must be GL_TEXTURE_2D.

This function may be called from any thread.

VuoShader VuoShader_makeUnlitCircleShader ( VuoColor  color,
VuoReal  sharpness 
)

Returns a shader that renders a solid color circle.

When sharpness = 1, the circle takes up half the size of the texture coordinates (circumscribing a rectangle from (0.25,0.25) to (0.75,0.75)).

When sharpness = 0, the circle's edge is blurred to take up the entire texture coordinate area.

This function may be called from any thread.

VuoShader VuoShader_makeUnlitColorShader ( VuoColor  color)

Returns a shader that renders a solid color.

This function may be called from any thread.

VuoShader VuoShader_makeUnlitImageShader ( VuoImage  image,
VuoReal  alpha 
)

Returns a shader that renders objects with an image (ignoring lighting).

image must be GL_TEXTURE_2D.

This function may be called from any thread.

VuoShader VuoShader_makeUnlitRoundedRectangleShader ( VuoColor  color,
VuoReal  sharpness,
VuoReal  roundness,
VuoReal  aspect 
)

Returns a shader that renders a solid color rounded rectangle.

When sharpness = 1, the rounded rectangle takes up half the size of the texture coordinates (from (0.25,0.25) to (0.75,0.75)).

When sharpness = 0, the rounded rectangle's edge is blurred to take up the entire texture coordinate area.

aspect specifies the aspect ratio of the rectangle.

This function may be called from any thread.

void VuoShader_release ( VuoShader  value)

Automatically generated function.

void VuoShader_resetContext ( VuoGlContext  glContext)

Disuses whatever shader (if any) is currently active on glContext.

This function may be called from any thread.

void VuoShader_retain ( VuoShader  value)

Automatically generated function.

VuoPoint2d VuoShader_samplerCoordinatesFromVuoCoordinates ( VuoPoint2d  vuoCoordinates,
VuoImage  image 
)

Converts the provided vuoCoordinates into GLSL Sampler Coordinates relative to the provided image.

Vuo Coordinates range from (-1,-1/aspectRatio) in the bottom left to (1,1/aspectRatio) in the top right.

GLSL Sampler Coordinates range from (0,0) to (1,1).

If image is rendered in a scene, centered at (0,0,0), width 2, at its correct aspect ratio, this function will transform 2D coordinates along the XY plane (at Z=0) into correct sampler coordinates for that image.

This function may be called from any thread.

VuoReal VuoShader_samplerSizeFromVuoSize ( VuoReal  vuoSize)

Converts an x-axis distance in Vuo Coordinates into GLSL Sampler Coordinates.

(Divides by 2.)

This function may be called from any thread.

void VuoShader_setExpectedOutputPrimitiveCount ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode,
const unsigned int  expectedOutputPrimitiveCount 
)

Specifies the number of primitives the geometry shader is expected to produce per invocation.

If this function is not called, the shader defaults to expecting 1 primitive.

Call before using VuoShader_getAttributeLocations, VuoShader_activate, and VuoShader_deactivate.

Parameters
shaderThe shader to modify.
inputPrimitiveModeThe shader program mode to modify.
expectedOutputPrimitiveCountThe number of primitives the geometry shader is expected to produce per invocation.

This function may be called from any thread.

void VuoShader_setFrostedGlassShaderValues ( VuoShader  shader,
VuoColor  color,
VuoReal  brightness,
VuoReal  noiseTime,
VuoReal  noiseAmount,
VuoReal  noiseScale,
VuoReal  chromaticAberration,
VuoInteger  levels,
VuoReal  roughness,
VuoReal  spacing,
VuoInteger  iterations 
)

Sets parameters for the frosted glass shader.

void VuoShader_setLinearGradientShaderValues ( VuoShader  shader,
VuoList_VuoColor  colors,
VuoPoint2d  start,
VuoPoint2d  end,
VuoReal  aspect,
VuoReal  noiseAmount 
)

Sets parameters for the linear gradient shader using the provided colors and start and end coordinates.

Coordinates should be passed in Vuo scene coordinates (-1,-1) to (1,1).

void VuoShader_setMayChangeOutputPrimitiveCount ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode,
const bool  mayChangeOutputPrimitiveCount 
)

Specifies whether the geometry shader may dynamically choose to skip outputting some primitives or output additional primitives.

If true, performance is potentially reduced since VuoSceneObjectRenderer will need to wait for the result of a query to determine the actual number of output primitives.

Call before using VuoShader_getAttributeLocations, VuoShader_activate, and VuoShader_deactivate.

Parameters
shaderThe shader to modify.
inputPrimitiveModeThe shader program mode to modify.
mayChangeOutputPrimitiveCountWhether the geometry shader may dynamically choose to skip outputting some primitives or output additional primitives.

This function may be called from any thread.

void VuoShader_setRadialGradientShaderValues ( VuoShader  shader,
VuoList_VuoColor  colors,
VuoPoint2d  center,
VuoReal  radius,
VuoReal  width,
VuoReal  height,
VuoReal  noiseAmount 
)

Sets parameters for the radial gradient shader using the provided colors, center point, and radius.

Center and radius are expected in Vuo scene coordinates. Width and Height may be either pixels or scene coordinates, as they are only used to calculate the aspect ratio.

void VuoShader_setUniform_VuoBoolean ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoBoolean  boolean 
)

Sets a bool uniform value on the specified shader.

This function may be called from any thread.

void VuoShader_setUniform_VuoColor ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoColor  colorUnpremultiplied 
)

Sets a color uniform value on the specified shader accepting a VuoColor.

color should be a normal un-premultiplied VuoColor; this function premultiplies its colors before passing it to the shader.

This function may be called from any thread.

void VuoShader_setUniform_VuoImage ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoImage  image 
)

Sets a VuoImage input value on the specified shader.

This function may be called from any thread.

void VuoShader_setUniform_VuoInteger ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoInteger  integer 
)

Sets an int uniform value on the specified shader.

This function may be called from any thread.

void VuoShader_setUniform_VuoPoint2d ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoPoint2d  point2d 
)

Sets a vec2 uniform value on the specified shader.

This function may be called from any thread.

void VuoShader_setUniform_VuoPoint3d ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoPoint3d  point3d 
)

Sets a vec3 uniform value on the specified shader.

This function may be called from any thread.

void VuoShader_setUniform_VuoPoint4d ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoPoint4d  point4d 
)

Sets a vec4 uniform value on the specified shader.

This function may be called from any thread.

void VuoShader_setUniform_VuoReal ( VuoShader  shader,
const char *  uniformIdentifier,
const VuoReal  real 
)

Sets a float uniform value on the specified shader.

This function may be called from any thread.