mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 03:52:45 +02:00
glowing box for black color
This commit is contained in:
parent
e8b6b32572
commit
97fe0170cb
2 changed files with 35 additions and 6 deletions
23
examples/painting/whiteboard/blackInk.fs
Normal file
23
examples/painting/whiteboard/blackInk.fs
Normal file
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
Script.scriptEnding.connect(cleanup);
|
Loading…
Reference in a new issue