From 97fe0170cbc5a20aa6d89dd83176082cbbe3e67d Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 15 Oct 2015 17:09:41 -0700 Subject: [PATCH] glowing box for black color --- examples/painting/whiteboard/blackInk.fs | 23 +++++++++++++++++++ .../painting/whiteboard/whiteboardSpawner.js | 18 ++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 examples/painting/whiteboard/blackInk.fs diff --git a/examples/painting/whiteboard/blackInk.fs b/examples/painting/whiteboard/blackInk.fs new file mode 100644 index 0000000000..1e77db285c --- /dev/null +++ b/examples/painting/whiteboard/blackInk.fs @@ -0,0 +1,23 @@ +vec2 iResolution = iWorldScale.xy; +vec2 iMouse = vec2(0); + +const float PI = 3.14159265; + +float time = iGlobalTime; +vec2 center = vec2(0.5, 0.5); +void mainImage( out vec4 fragColor, in vec2 fragCoord ) { + vec2 position = (fragCoord.xy/iResolution.xy) + 0.5; + float dist = pow(distance(position.xy, center), 3.); + dist = dist / 1.0 + sin(time * 10)/100.0; + vec3 color = vec3(dist, 0.0, dist); + fragColor = vec4(color, 1.0); +} + +vec4 getProceduralColor() { + vec4 result; + vec2 position = _position.xy; + + mainImage(result, position * iWorldScale.xy); + + return result; +} \ No newline at end of file diff --git a/examples/painting/whiteboard/whiteboardSpawner.js b/examples/painting/whiteboard/whiteboardSpawner.js index 13588d24a8..cbc26da670 100644 --- a/examples/painting/whiteboard/whiteboardSpawner.js +++ b/examples/painting/whiteboard/whiteboardSpawner.js @@ -81,7 +81,7 @@ var colorIndicatorBox = Entities.addEntity({ Entities.editEntity(whiteboard, { userData: JSON.stringify({ color: { - currentColor: colors[0], + currentColor: colors[0] }, colorIndicator: colorIndicatorBox }) @@ -120,12 +120,14 @@ for (var i = 0; i < colors.length; i++) { // BLACK BOX var blackBoxDimensions = { - x: .2, - y: .2, - z: 0.05 + x: 0.3, + y: 0.3, + z: 0.01 }; + colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + blackBoxDimensions.x / 2 - 0.01)); colorBoxPosition.y += 0.3; +var fragShaderURL = Script.resolvePath('blackInk.fs?v1' + Math.random()); var blackBox = Entities.addEntity({ type: 'Box', name: "Black Color", @@ -139,7 +141,11 @@ var blackBox = Entities.addEntity({ }, script: scriptURL, userData: JSON.stringify({ - whiteboard: whiteboard + whiteboard: whiteboard, + version: 2, + ProceduralEntity: { + shaderUrl: fragShaderURL + } }) }); @@ -192,4 +198,4 @@ function cleanup() { // Uncomment this line to delete whiteboard and all associated entity on script close -// Script.scriptEnding.connect(cleanup); \ No newline at end of file +Script.scriptEnding.connect(cleanup); \ No newline at end of file