Vuo
2.1.0
|
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.
To create a shader that supports rendering points, lines, and triangles to a framebuffer:
To render using that shader:
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 |
Typedefs | |
typedef struct _VuoShader * | VuoShader |
A graphics shader program, specifying how to render a 3D object or a 2D image. More... | |
Creating shaders from GLSL source code | |
VuoShader | VuoShader_make (const char *name) |
Creates a shader object, which contains multiple GL Program Objects. More... | |
VuoShader | VuoShader_makeFromFile (VuoShaderFile *shaderFile) |
Creates a shader object from a VuoShaderFile. More... | |
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 . More... | |
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. More... | |
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. More... | |
void | VuoShader_setTransparent (VuoShader shader, const bool isTransparent) |
See VuoShader::isTransparent . More... | |
#define | VUOSHADER_GLSL_SOURCE(version, source) "#version " #version "\n" #source |
A macro to facilitate defining a GLSL shader in a C source file. More... | |
Creating standard shaders | |
VuoShader | VuoShader_makeDefaultShader (void) |
Returns a shared instance of the default (unlit checkerboard) shader. More... | |
VuoShader | VuoShader_makeUnlitImageShader (VuoImage image, VuoReal alpha) |
Returns a shader that renders objects with an image (ignoring lighting). More... | |
VuoShader | VuoShader_makeUnlitAlphaPassthruImageShader (VuoImage image, bool flipped) |
Returns a shader that renders objects with an image (ignoring lighting). More... | |
VuoShader | VuoShader_makeGlTextureRectangleShader (VuoImage image, VuoReal alpha) |
Returns a shader that renders objects with an image (ignoring lighting). More... | |
VuoShader | VuoShader_makeGlTextureRectangleAlphaPassthruShader (VuoImage image, bool flipped) |
Returns a shader that renders objects with an image (ignoring lighting). More... | |
VuoShader | VuoShader_makeUnlitColorShader (VuoColor color) |
Returns a shader that renders a solid color . More... | |
VuoShader | VuoShader_makeUnlitCircleShader (VuoColor color, VuoReal sharpness) |
Returns a shader that renders a solid color circle. More... | |
VuoShader | VuoShader_makeUnlitRoundedRectangleShader (VuoColor color, VuoReal sharpness, VuoReal roundness, VuoReal aspect) |
Returns a shader that renders a solid color rounded rectangle. More... | |
VuoShader | VuoShader_makeUnlitRoundedRectangleTrackShader (VuoColor background, VuoColor active, VuoReal sharpness, VuoReal roundness, VuoReal aspect, VuoBoolean isHorizontal, VuoReal value) |
Returns a shader that renders a solid color rounded rectangle with a split color based on value. More... | |
VuoShader | VuoShader_makeUnlitCheckmarkShader (VuoColor color, VuoColor outline, float thickness) |
Returns a shader that renders a solid color checkmark with outline and outline thickness. More... | |
VuoShader | VuoShader_makeLitColorShader (VuoColor diffuseColor, VuoColor highlightColor, VuoReal shininess) |
Returns a shader that renders a color with lighting. More... | |
VuoShader | VuoShader_makeLitImageShader (VuoImage image, VuoReal alpha, VuoColor highlightColor, VuoReal shininess) |
Returns a shader that renders an image with lighting. More... | |
VuoShader | VuoShader_makeLitImageDetailsShader (VuoImage image, VuoReal alpha, VuoImage specularImage, VuoImage normalImage) |
Returns a shader that renders an image with lighting and surface details. More... | |
VuoShader | VuoShader_makeLinearGradientShader (void) |
Returns a linear gradient shader. More... | |
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. More... | |
VuoShader | VuoShader_makeRadialGradientShader (void) |
Returns a radial gradient shader. More... | |
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. More... | |
VuoShader | VuoShader_makeFrostedGlassShader (void) |
Returns a frosted glass shader. More... | |
void | VuoShader_setFrostedGlassShaderValues (VuoShader shader, VuoColor color, VuoReal brightness, VuoPoint2d noisePosition, VuoReal noiseTime, VuoReal noiseAmount, VuoReal noiseScale, VuoReal chromaticAberration, VuoInteger levels, VuoReal roughness, VuoReal spacing, VuoInteger iterations, float aspectRatio) |
Sets parameters for the frosted glass shader. More... | |
Using shaders | |
bool | VuoShader_isTransformFeedback (VuoShader shader) |
Returns true if each of shader 's defined inputPrimitiveMode s has a vertex shader (and optionally a geometry shader) but lacks a fragment shader. More... | |
unsigned int | VuoShader_getExpectedOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode) |
Returns the number of primitives the geometry shader is expected to produce per invocation. More... | |
bool | VuoShader_getMayChangeOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode) |
Returns true if the geometry shader may not output the expected primitive count. More... | |
bool | VuoShader_upload (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, void *outIssues) VuoWarnUnusedResult |
Compiles and uploads the shader, outputting any issues in a VuoShaderIssues instance. More... | |
bool | VuoShader_getAttributeLocations (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, int *positionLocation, int *normalLocation, int *textureCoordinateLocation, int *colorLocation) VuoWarnUnusedResult |
Outputs the shader program's vertex attribute locations (the same values as glGetAttribLocation() ). More... | |
bool | VuoShader_activate (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, VuoGlProgram *outputProgram) VuoWarnUnusedResult |
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. More... | |
void | VuoShader_deactivate (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext) |
Unbinds the shader's images from their texture units. More... | |
void | VuoShader_resetContext (VuoGlContext glContext) |
Disuses whatever shader (if any) is currently active on glContext . More... | |
void | VuoShader_setUniform_VuoImage (VuoShader shader, const char *uniformIdentifier, const VuoImage image) |
Sets a VuoImage input value on the specified shader . More... | |
void | VuoShader_setUniform_VuoBoolean (VuoShader shader, const char *uniformIdentifier, const VuoBoolean boolean) |
Sets a bool uniform value on the specified shader . More... | |
void | VuoShader_setUniform_VuoInteger (VuoShader shader, const char *uniformIdentifier, const VuoInteger integer) |
Sets an int uniform value on the specified shader . More... | |
void | VuoShader_setUniform_VuoReal (VuoShader shader, const char *uniformIdentifier, const VuoReal real) |
Sets a float uniform value on the specified shader . More... | |
void | VuoShader_setUniform_VuoPoint2d (VuoShader shader, const char *uniformIdentifier, const VuoPoint2d point2d) |
Sets a vec2 uniform value on the specified shader . More... | |
void | VuoShader_setUniform_VuoPoint3d (VuoShader shader, const char *uniformIdentifier, const VuoPoint3d point3d) |
Sets a vec3 uniform value on the specified shader . More... | |
void | VuoShader_setUniform_VuoPoint4d (VuoShader shader, const char *uniformIdentifier, const VuoPoint4d point4d) |
Sets a vec4 uniform value on the specified shader . More... | |
void | VuoShader_setUniform_VuoColor (VuoShader shader, const char *uniformIdentifier, const VuoColor color) |
Sets a color uniform value on the specified shader accepting a VuoColor. More... | |
void | VuoShader_setUniform_VuoList_VuoBoolean (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoBoolean booleans) |
Sets a list of bool uniform values on the specified shader . More... | |
void | VuoShader_setUniform_VuoList_VuoInteger (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoInteger integers) |
Sets a list of int uniform values on the specified shader . More... | |
void | VuoShader_setUniform_VuoList_VuoReal (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoReal reals) |
Sets a list of float uniform values on the specified shader . More... | |
void | VuoShader_setUniform_VuoList_VuoPoint2d (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint2d point2ds) |
Sets a list of vec2 uniform values on the specified shader . More... | |
void | VuoShader_setUniform_VuoList_VuoPoint3d (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint3d point3ds) |
Sets a list of vec3 uniform values on the specified shader . More... | |
void | VuoShader_setUniform_VuoList_VuoPoint4d (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint4d point4ds) |
Sets a list of vec4 uniform values on the specified shader . More... | |
void | VuoShader_setUniform_VuoList_VuoColor (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoColor colors) |
Sets a list of color uniform values on the specified shader 's uniform uniformIdentifier of type vec4 . More... | |
void | VuoShader_setUniform_mat2 (VuoShader shader, const char *uniformIdentifier, float *mat2) |
Sets a mat2 (column-major 2x2 matrix) uniform value on the specified shader . More... | |
void | VuoShader_setUniform_mat3 (VuoShader shader, const char *uniformIdentifier, float *mat3) |
Sets a mat3 (column-major 3x3 matrix) uniform value on the specified shader . More... | |
void | VuoShader_setUniform_mat4 (VuoShader shader, const char *uniformIdentifier, float *mat4) |
Sets a mat4 (column-major 4x4 matrix) uniform value on the specified shader . More... | |
VuoShader | VuoShader_make_VuoColor (VuoColor color) |
Creates an unlit color shader object. More... | |
VuoShader | VuoShader_make_VuoShader (VuoShader shader) |
Returns the passed shader (does not make a copy). More... | |
VuoShader | VuoShader_make_VuoImage (VuoImage image) |
Creates an unlit image shader. More... | |
VuoImage | VuoShader_getUniform_VuoImage (VuoShader shader, const char *uniformIdentifier) |
Returns the VuoImage for the specified uniformIdentifier , or NULL if none matches. More... | |
VuoImage | VuoShader_getFirstImage (VuoShader shader) |
Returns the first-added, non-NULL VuoImage uniform value, or NULL if there are no image uniforms. More... | |
VuoPoint2d | VuoShader_samplerCoordinatesFromVuoCoordinates (VuoPoint2d vuoCoordinates, VuoImage image) |
Converts the provided vuoCoordinates into GLSL Sampler Coordinates relative to the provided image . More... | |
VuoReal | VuoShader_samplerSizeFromVuoSize (VuoReal vuoSize) |
Converts an x-axis distance in Vuo Coordinates into GLSL Sampler Coordinates. More... | |
VuoPoint2d | VuoShader_samplerRectCoordinatesFromNormalizedCoordinates (VuoPoint2d normalizedCoordinates, VuoInteger imageWidth, VuoInteger imageHeight) |
Converts the provided normalizedCoordinates into GLSL sampler2DRect coordinates relative to the provided width/height. More... | |
bool | VuoShader_isOpaque (VuoShader shader) |
Returns true if the shader, as configured, will produce fully opaque output. More... | |
bool | VuoShader_isPopulated (VuoShader shader) |
Returns true if the shader is anything other than the default (blue/purple gradient checkerboard). More... | |
Summary, serialization, and reference counting | |
char * | VuoShader_getSummary (const VuoShader value) |
Returns a summary of the shader: the text description provided to VuoShader_make. More... | |
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 . More... | |
struct json_object * | VuoShader_getJson (const VuoShader value) |
Encodes value as a JSON object. More... | |
struct json_object * | VuoShader_getInterprocessJson (const VuoShader value) |
Calls VuoShader_getJson(). More... | |
VuoShader | VuoShader_makeFromString (const char *str) |
Automatically generated function. More... | |
char * | VuoShader_getString (const VuoShader value) |
Automatically generated function. More... | |
void | VuoShader_retain (VuoShader value) |
Automatically generated function. More... | |
void | VuoShader_release (VuoShader value) |
Automatically generated function. More... | |
#define | VuoShader_REQUIRES_INTERPROCESS_JSON |
This type has a _getInterprocessJson() function. More... | |
struct VuoSubshader |
Class Members | ||
---|---|---|
VuoBoolean | compilationAttempted | If true, we've already attempted to compile this subshader. |
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 | ||
---|---|---|
unsigned int | compiledTextureTarget |
For uniforms of type Image, this holds the OpenGL texture target used when expanding the source code. This is set during VuoShader_ensureUploaded (not during VuoShader_setUniform_VuoImage). |
VuoText | name | |
VuoText | type | |
union VuoShaderUniform | value |
union VuoShaderUniform.value |
Class Members | ||
---|---|---|
VuoBoolean | boolean | |
VuoList_VuoBoolean | booleans | |
VuoColor | color | |
VuoList_VuoColor | colors | |
VuoImage | image | |
VuoInteger | integer | |
VuoList_VuoInteger | integers | |
float * | mat2 | |
float * | mat3 | |
float * | mat4 | |
VuoPoint2d | point2d | |
VuoList_VuoPoint2d | point2ds | |
VuoPoint3d | point3d | |
VuoList_VuoPoint3d | point3ds | |
VuoPoint4d | point4d | |
VuoList_VuoPoint4d | point4ds | |
VuoReal | real | |
VuoList_VuoReal | reals |
#define VUOSHADER_GLSL_SOURCE | ( | version, | |
source | |||
) | "#version " #version "\n" #source |
A macro to facilitate defining a GLSL shader in a C source file.
Definition at line 208 of file VuoShader.h.
#define VuoShader_REQUIRES_INTERPROCESS_JSON |
This type has a _getInterprocessJson() function.
Definition at line 295 of file VuoShader.h.
typedef struct _VuoShader * VuoShader |
A graphics shader program, specifying how to render a 3D object or a 2D image.
activationCount
, lastActivationTime
. 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.
shader | The shader to activate. |
inputPrimitiveMode | The shader program mode to activate. |
glContext | The OpenGL context on which to activate the shader program. |
outputProgram | The OpenGL program name and metadata. |
inputPrimitiveMode
is invalidinputPrimitiveMode
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.)
Definition at line 939 of file VuoShader.cc.
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 inputPrimitiveMode
s.
Call before using VuoShader_getAttributeLocations, VuoShader_activate, and VuoShader_deactivate.
shader | The shader to modify. |
inputPrimitiveMode | The type of input primitives this shader program will process. Should be VuoMesh_IndividualTriangles, VuoMesh_IndividualLines, or VuoMesh_Points. |
vertexShaderSource | GLSL vertex shader source code. If NULL , a default vertex shader is used (it passes texture coordinates through, and projects the vertex). |
geometryShaderSource | GLSL geometry shader source code. Optional (may be NULL ), in which case the output of the vertex shader is passed through to the fragment shader. |
fragmentShaderSource | GLSL 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. |
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 vec3 position; // required attribute vec3 normal; attribute vec2 textureCoordinate; attribute vec4 vertexColor; uniform bool hasTextureCoordinates; uniform bool hasVertexColors;
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 vec3 position; attribute vec3 normal; attribute vec2 textureCoordinate; attribute vec4 vertexColor;
And it expects as output:
varying vec3 outPosition; varying vec3 outNormal; varying vec2 outTextureCoordinate; varying vec4 outVertexColor;
This function may be called from any thread.
Definition at line 311 of file VuoShader.cc.
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
shader | The shader to deactivate. |
inputPrimitiveMode | The shader program mode to deactivate. |
glContext | The 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.)
Definition at line 1336 of file VuoShader.cc.
bool VuoShader_getAttributeLocations | ( | VuoShader | shader, |
const VuoMesh_ElementAssemblyMethod | inputPrimitiveMode, | ||
VuoGlContext | glContext, | ||
int * | positionLocation, | ||
int * | normalLocation, | ||
int * | textureCoordinateLocation, | ||
int * | colorLocation | ||
) |
Outputs the shader program's vertex attribute locations (the same values as glGetAttribLocation()
).
If necessary, this function also compiles, links, and uploads the program.
shader | The shader to query. | |
inputPrimitiveMode | The shader program mode to query. | |
glContext | An OpenGL context to use. | |
[out] | positionLocation | Outputs the shader program's vertex position attribute location. Pass NULL if you don't care. |
[out] | normalLocation | Outputs 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] | textureCoordinateLocation | Outputs 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. |
[out] | colorLocation | Outputs the shader program's vertex color attribute location (or -1 if this shader program doesn't have one). Pass NULL if you don't care. |
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.)
Definition at line 767 of file VuoShader.cc.
unsigned int VuoShader_getExpectedOutputPrimitiveCount | ( | VuoShader | shader, |
const VuoMesh_ElementAssemblyMethod | inputPrimitiveMode | ||
) |
Returns the number of primitives the geometry shader is expected to produce per invocation.
shader | The shader to query. |
inputPrimitiveMode | The shader program mode to query. |
This function may be called from any thread.
Definition at line 460 of file VuoShader.cc.
Returns the first-added, non-NULL VuoImage
uniform value, or NULL if there are no image uniforms.
Definition at line 325 of file VuoShaderUniforms.h.
struct json_object* VuoShader_getInterprocessJson | ( | const VuoShader | value | ) |
Calls VuoShader_getJson().
Interprocess support is not yet implemented.
This function may be called from any thread.
Definition at line 1470 of file VuoShader.cc.
struct json_object* VuoShader_getJson | ( | const VuoShader | value | ) |
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.
Definition at line 1455 of file VuoShader.cc.
bool VuoShader_getMayChangeOutputPrimitiveCount | ( | VuoShader | shader, |
const VuoMesh_ElementAssemblyMethod | inputPrimitiveMode | ||
) |
Returns true if the geometry shader may not output the expected primitive count.
shader | The shader to query. |
inputPrimitiveMode | The shader program mode to query. |
This function may be called from any thread.
Definition at line 483 of file VuoShader.cc.
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.
Definition at line 1480 of file VuoShader.cc.
Returns the VuoImage
for the specified uniformIdentifier
, or NULL if none matches.
Definition at line 304 of file VuoShaderUniforms.h.
bool VuoShader_isOpaque | ( | VuoShader | shader | ) |
Returns true if the shader, as configured, will produce fully opaque output.
Returns false if:
isTransparent
or useAlphaAsCoverage
is set)alpha
whose value is less than 1Definition at line 1550 of file VuoShader.cc.
bool VuoShader_isPopulated | ( | VuoShader | shader | ) |
Returns true if the shader is anything other than the default (blue/purple gradient checkerboard).
Definition at line 1613 of file VuoShader.cc.
bool VuoShader_isTransformFeedback | ( | VuoShader | shader | ) |
Returns true
if each of shader
's defined inputPrimitiveMode
s has a vertex shader (and optionally a geometry shader) but lacks a fragment shader.
This function may be called from any thread.
Definition at line 503 of file VuoShader.cc.
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.
name | Text 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.
Definition at line 123 of file VuoShader.cc.
Creates an unlit color shader object.
Definition at line 177 of file VuoShader.cc.
Creates an unlit image shader.
Definition at line 200 of file VuoShader.cc.
Returns the passed shader (does not make a copy).
Definition at line 189 of file VuoShader.cc.
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.
Definition at line 134 of file VuoShaderShaders.h.
VuoShader VuoShader_makeFromFile | ( | VuoShaderFile * | shaderFile | ) |
Creates a shader object from a VuoShaderFile.
Don't call VuoShader_addSource; the sources are automatically retrieved from the VuoShaderFile.
This function may be called from any thread.
Definition at line 160 of file VuoShader.cc.
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.
Definition at line 1435 of file VuoShader.cc.
VuoShader VuoShader_makeFromString | ( | const char * | str | ) |
Automatically generated function.
VuoShader VuoShader_makeFrostedGlassShader | ( | void | ) |
Returns a frosted glass shader.
Definition at line 1385 of file VuoShaderShaders.h.
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.
Definition at line 343 of file VuoShaderShaders.h.
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.
Definition at line 302 of file VuoShaderShaders.h.
VuoShader VuoShader_makeLinearGradientShader | ( | void | ) |
Returns a linear gradient shader.
This function may be called from any thread.
Definition at line 1180 of file VuoShaderShaders.h.
VuoShader VuoShader_makeLitColorShader | ( | VuoColor | diffuseColor, |
VuoColor | highlightColor, | ||
VuoReal | shininess | ||
) |
Returns a shader that renders a color with lighting.
diffuseColor | The primary material color. |
highlightColor | The color of shiny specular highlights. Alpha controls the intensity of the highlights. |
shininess | A 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.
Definition at line 822 of file VuoShaderShaders.h.
VuoShader VuoShader_makeLitImageDetailsShader | ( | VuoImage | image, |
VuoReal | alpha, | ||
VuoImage | specularImage, | ||
VuoImage | normalImage | ||
) |
Returns a shader that renders an image with lighting and surface details.
image | The image which provides the diffuse / primary material color. |
alpha | The opacity of the image (0 to 1). |
specularImage | An image that specifies the specular color (RGB) and shininess (A). |
normalImage | An 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.
Definition at line 1050 of file VuoShaderShaders.h.
VuoShader VuoShader_makeLitImageShader | ( | VuoImage | image, |
VuoReal | alpha, | ||
VuoColor | highlightColor, | ||
VuoReal | shininess | ||
) |
Returns a shader that renders an image with lighting.
image | The image which provides the diffuse / primary material color. |
alpha | The opacity of the image (0 to 1). |
highlightColor | The color of shiny specular highlights. Alpha controls the intensity of the highlights. |
shininess | A 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.
Definition at line 975 of file VuoShaderShaders.h.
VuoShader VuoShader_makeRadialGradientShader | ( | void | ) |
Returns a radial gradient shader.
This function may be called from any thread.
Definition at line 1322 of file VuoShaderShaders.h.
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.
Definition at line 250 of file VuoShaderShaders.h.
Returns a shader that renders a solid color
checkmark with outline and outline thickness.
This function may be called from any thread.
Definition at line 520 of file VuoShaderShaders.h.
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.
Definition at line 480 of file VuoShaderShaders.h.
Returns a shader that renders a solid color
.
This function may be called from any thread.
Definition at line 395 of file VuoShaderShaders.h.
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.
Definition at line 163 of file VuoShaderShaders.h.
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.
Definition at line 605 of file VuoShaderShaders.h.
VuoShader VuoShader_makeUnlitRoundedRectangleTrackShader | ( | VuoColor | backgroundColor, |
VuoColor | activeColor, | ||
VuoReal | sharpness, | ||
VuoReal | roundness, | ||
VuoReal | aspect, | ||
VuoBoolean | isHorizontal, | ||
VuoReal | value | ||
) |
Returns a shader that renders a solid color
rounded rectangle with a split color based on value.
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.
Definition at line 707 of file VuoShaderShaders.h.
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.
Definition at line 1417 of file VuoShader.cc.
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.
Definition at line 1500 of file VuoShader.cc.
VuoPoint2d VuoShader_samplerRectCoordinatesFromNormalizedCoordinates | ( | VuoPoint2d | c, |
VuoInteger | imageWidth, | ||
VuoInteger | imageHeight | ||
) |
Converts the provided normalizedCoordinates
into GLSL sampler2DRect coordinates relative to the provided width/height.
GLSL Normalized Sampler Coordinates range from (0,0) in the bottom left to (1,1) in the top right.
GLSL sampler2DRect Coordinates range from (0,0) to (imageWidth,imageHeight).
This function may be called from any thread.
Definition at line 1528 of file VuoShader.cc.
Converts an x-axis distance in Vuo Coordinates into GLSL Sampler Coordinates.
(Divides by 2.)
This function may be called from any thread.
Definition at line 1513 of file VuoShader.cc.
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.
shader | The shader to modify. |
inputPrimitiveMode | The shader program mode to modify. |
expectedOutputPrimitiveCount | The number of primitives the geometry shader is expected to produce per invocation. |
This function may be called from any thread.
Definition at line 399 of file VuoShader.cc.
void VuoShader_setFrostedGlassShaderValues | ( | VuoShader | shader, |
VuoColor | color, | ||
VuoReal | brightness, | ||
VuoPoint2d | noisePosition, | ||
VuoReal | noiseTime, | ||
VuoReal | noiseAmount, | ||
VuoReal | noiseScale, | ||
VuoReal | chromaticAberration, | ||
VuoInteger | levels, | ||
VuoReal | roughness, | ||
VuoReal | spacing, | ||
VuoInteger | iterations, | ||
float | aspectRatio | ||
) |
Sets parameters for the frosted glass shader.
noisePosition
and aspectRatio
arguments. Definition at line 1557 of file VuoShaderShaders.h.
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).
Definition at line 1308 of file VuoShaderShaders.h.
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.
shader | The shader to modify. |
inputPrimitiveMode | The shader program mode to modify. |
mayChangeOutputPrimitiveCount | Whether the geometry shader may dynamically choose to skip outputting some primitives or output additional primitives. |
This function may be called from any thread.
Definition at line 425 of file VuoShader.cc.
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.
Definition at line 1370 of file VuoShaderShaders.h.
void VuoShader_setTransparent | ( | VuoShader | shader, |
const bool | isTransparent | ||
) |
See VuoShader::isTransparent
.
This function may be called from any thread.
Definition at line 444 of file VuoShader.cc.
void VuoShader_setUniform_mat2 | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
float * | mat2 | ||
) |
Sets a mat2
(column-major 2x2 matrix) uniform value on the specified shader
.
This function may be called from any thread.
Definition at line 273 of file VuoShaderUniforms.h.
void VuoShader_setUniform_mat3 | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
float * | mat3 | ||
) |
Sets a mat3
(column-major 3x3 matrix) uniform value on the specified shader
.
This function may be called from any thread.
Definition at line 284 of file VuoShaderUniforms.h.
void VuoShader_setUniform_mat4 | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
float * | mat4 | ||
) |
Sets a mat4
(column-major 4x4 matrix) uniform value on the specified shader
.
This function may be called from any thread.
Definition at line 295 of file VuoShaderUniforms.h.
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.
Definition at line 113 of file VuoShaderUniforms.h.
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.
Definition at line 176 of file VuoShaderUniforms.h.
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.
Definition at line 103 of file VuoShaderUniforms.h.
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.
Definition at line 123 of file VuoShaderUniforms.h.
void VuoShader_setUniform_VuoList_VuoBoolean | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
const VuoList_VuoBoolean | booleans | ||
) |
Sets a list of bool
uniform values on the specified shader
.
This function may be called from any thread.
Definition at line 188 of file VuoShaderUniforms.h.
void VuoShader_setUniform_VuoList_VuoColor | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
const VuoList_VuoColor | colorsP | ||
) |
Sets a list of color uniform values on the specified shader
's uniform uniformIdentifier
of type vec4
.
colors
should be a list of normal un-premultiplied VuoColors; this function premultiplies each color before passing it to the shader.
This function may be called from any thread.
Definition at line 257 of file VuoShaderUniforms.h.
void VuoShader_setUniform_VuoList_VuoInteger | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
const VuoList_VuoInteger | integers | ||
) |
Sets a list of int
uniform values on the specified shader
.
This function may be called from any thread.
Definition at line 199 of file VuoShaderUniforms.h.
void VuoShader_setUniform_VuoList_VuoPoint2d | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
const VuoList_VuoPoint2d | point2ds | ||
) |
Sets a list of vec2
uniform values on the specified shader
.
This function may be called from any thread.
Definition at line 221 of file VuoShaderUniforms.h.
void VuoShader_setUniform_VuoList_VuoPoint3d | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
const VuoList_VuoPoint3d | point3ds | ||
) |
Sets a list of vec3
uniform values on the specified shader
.
This function may be called from any thread.
Definition at line 232 of file VuoShaderUniforms.h.
void VuoShader_setUniform_VuoList_VuoPoint4d | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
const VuoList_VuoPoint4d | point4ds | ||
) |
Sets a list of vec4
uniform values on the specified shader
.
This function may be called from any thread.
Definition at line 243 of file VuoShaderUniforms.h.
void VuoShader_setUniform_VuoList_VuoReal | ( | VuoShader | shader, |
const char * | uniformIdentifier, | ||
const VuoList_VuoReal | reals | ||
) |
Sets a list of float
uniform values on the specified shader
.
This function may be called from any thread.
Definition at line 210 of file VuoShaderUniforms.h.
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.
Definition at line 143 of file VuoShaderUniforms.h.
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.
Definition at line 153 of file VuoShaderUniforms.h.
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.
Definition at line 163 of file VuoShaderUniforms.h.
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.
Definition at line 133 of file VuoShaderUniforms.h.
bool VuoShader_upload | ( | VuoShader | shader, |
const VuoMesh_ElementAssemblyMethod | inputPrimitiveMode, | ||
VuoGlContext | glContext, | ||
void * | outIssues | ||
) |
Compiles and uploads the shader, outputting any issues in a VuoShaderIssues instance.
This is optional; the shader will automatically be compiled and uploaded when needed. It's only necessary if you want to get the compilation warnings/errors.
false
if the shader is NULL, or if it doesn't support the specified primitiveMode
, or if the shader fails to compile or link.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.)
Definition at line 735 of file VuoShader.cc.