Vuo  2.4.0
VuoShader.h
Go to the documentation of this file.
1
10#pragma once
11
12#include "VuoColor.h"
13#include "VuoHeap.h"
14#include "VuoImage.h"
15#include "VuoInteger.h"
16#include "VuoMesh.h"
17#include "VuoPoint2d.h"
18#include "VuoPoint3d.h"
19#include "VuoPoint4d.h"
20#include "VuoReal.h"
21#include "VuoText.h"
22#include "VuoGlContext.h"
23#include "VuoList_VuoInteger.h"
24#include "VuoList_VuoImage.h"
25#include "VuoList_VuoColor.h"
26#include "VuoList_VuoPoint4d.h"
27#include "VuoList_VuoText.h"
28#include "VuoGlPool.h"
29
30#ifdef __cplusplus
31class VuoShaderFile;
32#else
33typedef void *VuoShaderFile;
34#endif
35
90typedef struct
91{
93 unsigned int glVertexShaderName;
94
96 unsigned int glGeometryShaderName;
97 unsigned int expectedOutputPrimitiveCount;
98 bool mayChangeOutputPrimitiveCount;
99
101 unsigned int glFragmentShaderName;
102
103 VuoGlProgram program;
104
107
113typedef struct
114{
117 union
118 {
119 VuoImage image;
120 VuoBoolean boolean;
121 VuoInteger integer;
122 VuoReal real;
123 VuoPoint2d point2d;
124 VuoPoint3d point3d;
125 VuoPoint4d point4d;
126 VuoColor color;
127 VuoList_VuoBoolean booleans;
128 VuoList_VuoInteger integers;
129 VuoList_VuoReal reals;
130 VuoList_VuoPoint2d point2ds;
131 VuoList_VuoPoint3d point3ds;
132 VuoList_VuoPoint4d point4ds;
133 VuoList_VuoColor colors;
134 float *mat2;
135 float *mat3;
136 float *mat4;
137 } value;
138
146
152typedef struct _VuoShader
153{
154 VuoText name;
155
156 VuoSubshader pointProgram;
157 VuoSubshader lineProgram;
158 VuoSubshader triangleProgram;
159
160 VuoShaderUniform *uniforms;
161 unsigned int uniformsCount;
162
163 float objectScale;
164
172 bool isTransparent;
173
186 bool useAlphaAsCoverage;
187
188 VuoImage colorBuffer;
189 VuoImage depthBuffer;
190
191 uint64_t activationCount;
192 VuoReal lastActivationTime;
193
194 void *lock;
196
197
200VuoShader VuoShader_make(const char *name);
202void VuoShader_addSource(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const char *vertexShaderSource, const char *geometryShaderSource, const char *fragmentShaderSource);
203void VuoShader_setExpectedOutputPrimitiveCount(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const unsigned int expectedOutputPrimitiveCount);
204void VuoShader_setMayChangeOutputPrimitiveCount(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const bool mayChangeOutputPrimitiveCount);
205void VuoShader_setTransparent(VuoShader shader, const bool isTransparent);
206
208#define VUOSHADER_GLSL_SOURCE(version,source) "#version " #version "\n" #source
210
211
219
223VuoShader VuoShader_makeUnlitRoundedRectangleTrackShader(VuoColor background, VuoColor active, VuoReal sharpness, VuoReal roundness, VuoReal aspect, VuoBoolean isHorizontal, VuoReal value);
224VuoShader VuoShader_makeUnlitCheckmarkShader(VuoColor color, VuoColor outline, float thickness);
225
226VuoShader VuoShader_makeLitColorShader(VuoColor diffuseColor, VuoColor highlightColor, VuoReal shininess);
227VuoShader VuoShader_makeLitImageShader(VuoImage image, VuoReal alpha, VuoColor highlightColor, VuoReal shininess);
228VuoShader VuoShader_makeLitImageDetailsShader(VuoImage image, VuoReal alpha, VuoImage specularImage, VuoImage normalImage);
229
231void VuoShader_setLinearGradientShaderValues(VuoShader shader, VuoList_VuoColor colors, VuoPoint2d start, VuoPoint2d end, VuoReal aspect, VuoReal noiseAmount);
232
234void VuoShader_setRadialGradientShaderValues(VuoShader shader, VuoList_VuoColor colors, VuoPoint2d center, VuoReal radius, VuoReal width, VuoReal height, VuoReal noiseAmount);
235
237void 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);
239
240
244unsigned int VuoShader_getExpectedOutputPrimitiveCount(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode);
246
247bool VuoShader_upload(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, void *outIssues) VuoWarnUnusedResult;
248bool VuoShader_getAttributeLocations(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, int *positionLocation, int *normalLocation, int *textureCoordinateLocation, int *colorLocation) VuoWarnUnusedResult;
249bool VuoShader_activate(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, VuoGlProgram *outputProgram) VuoWarnUnusedResult;
250void VuoShader_deactivate(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext);
252
253void VuoShader_setUniform_VuoImage (VuoShader shader, const char *uniformIdentifier, const VuoImage image);
254void VuoShader_setUniform_VuoBoolean(VuoShader shader, const char *uniformIdentifier, const VuoBoolean boolean);
255void VuoShader_setUniform_VuoInteger(VuoShader shader, const char *uniformIdentifier, const VuoInteger integer);
256void VuoShader_setUniform_VuoReal (VuoShader shader, const char *uniformIdentifier, const VuoReal real);
257void VuoShader_setUniform_VuoPoint2d(VuoShader shader, const char *uniformIdentifier, const VuoPoint2d point2d);
258void VuoShader_setUniform_VuoPoint3d(VuoShader shader, const char *uniformIdentifier, const VuoPoint3d point3d);
259void VuoShader_setUniform_VuoPoint4d(VuoShader shader, const char *uniformIdentifier, const VuoPoint4d point4d);
260void VuoShader_setUniform_VuoColor (VuoShader shader, const char *uniformIdentifier, const VuoColor color);
261void VuoShader_setUniform_VuoList_VuoBoolean(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoBoolean booleans);
262void VuoShader_setUniform_VuoList_VuoInteger(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoInteger integers);
263void VuoShader_setUniform_VuoList_VuoReal (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoReal reals);
264void VuoShader_setUniform_VuoList_VuoPoint2d(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint2d point2ds);
265void VuoShader_setUniform_VuoList_VuoPoint3d(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint3d point3ds);
266void VuoShader_setUniform_VuoList_VuoPoint4d(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint4d point4ds);
267void VuoShader_setUniform_VuoList_VuoColor (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoColor colors);
268void VuoShader_setUniform_mat2 (VuoShader shader, const char *uniformIdentifier, float *mat2);
269void VuoShader_setUniform_mat3 (VuoShader shader, const char *uniformIdentifier, float *mat3);
270void VuoShader_setUniform_mat4 (VuoShader shader, const char *uniformIdentifier, float *mat4);
271
275
276VuoImage VuoShader_getUniform_VuoImage(VuoShader shader, const char *uniformIdentifier);
278
279VuoPoint2d VuoShader_samplerCoordinatesFromVuoCoordinates(VuoPoint2d vuoCoordinates, VuoImage image);
281VuoPoint2d VuoShader_samplerRectCoordinatesFromNormalizedCoordinates(VuoPoint2d normalizedCoordinates, VuoInteger imageWidth, VuoInteger imageHeight);
282
283bool VuoShader_isOpaque(VuoShader shader);
286
287
290char * VuoShader_getSummary(const VuoShader value);
292struct json_object * VuoShader_getJson(const VuoShader value);
293
295#define VuoShader_REQUIRES_INTERPROCESS_JSON
297
301char * VuoShader_getString(const VuoShader value);
307
308