/** * Finds and returns all the lights in the scene. * * If there are multiple ambient lights, returns the weighted (by alpha) average color and summed brightness. * * If there are no lights in the scene, returns some default lights. */ void VuoSceneObject_findLights(VuoSceneObject so, VuoColor *ambientColor, float *ambientBrightness, VuoList_VuoSceneObject *pointLights, VuoList_VuoSceneObject *spotLights) { VuoList_VuoColor ambientColors = VuoListCreate_VuoColor(); VuoRetain(ambientColors); *ambientBrightness = 0; *pointLights = VuoListCreate_VuoSceneObject(); *spotLights = VuoListCreate_VuoSceneObject(); float localModelviewMatrix[16]; VuoTransform_getMatrix(VuoTransform_makeIdentity(), localModelviewMatrix); VuoSceneObject_findLightsRecursive(so, localModelviewMatrix, ambientColors, ambientBrightness, *pointLights, *spotLights); if (!VuoListGetCount_VuoColor(ambientColors) && !VuoListGetCount_VuoSceneObject(*pointLights) && !VuoListGetCount_VuoSceneObject(*spotLights)) { *ambientColor = VuoColor_makeWithRGBA(1,1,1,1); *ambientBrightness = 0.05; // https://en.wikipedia.org/wiki/Three-point_lighting VuoSceneObject keyLight = VuoSceneObject_makePointLight(VuoColor_makeWithRGBA(1,1,1,1), .70, VuoPoint3d_make(-1,1,1), 5, .5); VuoListAppendValue_VuoSceneObject(*pointLights, keyLight); VuoSceneObject fillLight = VuoSceneObject_makePointLight(VuoColor_makeWithRGBA(1,1,1,1), .2, VuoPoint3d_make(.5,0,1), 5, 0); VuoListAppendValue_VuoSceneObject(*pointLights, fillLight); VuoSceneObject backLight = VuoSceneObject_makePointLight(VuoColor_makeWithRGBA(1,1,1,1), .15, VuoPoint3d_make(1,.75,-.5), 5, 0); VuoListAppendValue_VuoSceneObject(*pointLights, backLight); } else *ambientColor = VuoColor_average(ambientColors); VuoRelease(ambientColors); }
void nodeInstanceEvent ( VuoInstanceData(struct nodeInstanceData *) instance, VuoInputData(VuoList_VuoColor, {"default":[{"r":1,"g":1,"b":1,"a":1}, {"r":0,"g":0,"b":0,"a":1}]}) colors, // VuoInputEvent({"eventBlocking":"none","data":"colors"}) colorsEvent, VuoInputData(VuoPoint2d, {"default":{"x":0,"y":0}, "suggestedStep":{"x":0.1,"y":0.1}}) center, VuoInputData(VuoReal, {"default":1, "suggestedMin":0, "suggestedStep":0.1}) radius, VuoInputData(VuoInteger, {"default":640, "suggestedMin":1, "suggestedStep":32}) width, VuoInputData(VuoInteger, {"default":480, "suggestedMin":1, "suggestedStep":32}) height, VuoOutputData(VuoImage) image ) { // VuoPoint2d scale = width < height ? VuoPoint2d_make(1., height/(float)width) : VuoPoint2d_make(width/(float)height, 1.); VuoPoint2d scale = VuoPoint2d_make(1., height/(float)width); int len = VuoListGetCount_VuoColor(colors); unsigned char* pixels = (unsigned char*)malloc(sizeof(char)*len*4); int n = 0; for(int i = 1; i <= len; i++) { VuoColor col = VuoListGetValue_VuoColor(colors, i); pixels[n++] = (unsigned int)(col.a*col.r*255); pixels[n++] = (unsigned int)(col.a*col.g*255); pixels[n++] = (unsigned int)(col.a*col.b*255); pixels[n++] = (unsigned int)(col.a*255); } VuoImage gradientStrip = VuoImage_makeFromBuffer(pixels, GL_RGBA, len, 1, VuoImageColorDepth_8); VuoShader_setUniform_VuoImage ((*instance)->shader, "gradientStrip", gradientStrip); VuoShader_setUniform_VuoReal ((*instance)->shader, "gradientCount", len);
"title" : "Convert Color List to DMX", "keywords" : [ "artnet", "art net", "art-net", "fixture", "lamp", "lighting", "rgbaw", "rgbw", "wwcw", "ww/cw" ], "version" : "1.0.0", "node": { "exampleCompositions" : [ ] } }); void nodeEvent ( VuoInputData(VuoList_VuoColor) colors, VuoInputData(VuoDmxColorMap, {"default":"rgb"}) colorMap, VuoOutputData(VuoList_VuoInteger, {"name":"DMX"}) dmx ) { VuoInteger colorCount = VuoListGetCount_VuoColor(colors); *dmx = VuoListCreate_VuoInteger(); for (VuoInteger i = 1; i <= colorCount; ++i) { VuoColor c = VuoListGetValue_VuoColor(colors, i); // How similar is the color to white (255,255,255)? VuoReal whiteness = c.a * (c.r + c.g + c.b) / 3; if (colorMap == VuoDmxColorMap_RGB) { VuoListAppendValue_VuoInteger(*dmx, c.r * c.a * 255); VuoListAppendValue_VuoInteger(*dmx, c.g * c.a * 255); VuoListAppendValue_VuoInteger(*dmx, c.b * c.a * 255); } else if (colorMap == VuoDmxColorMap_RGBA)