diff --git a/package.json b/package.json
index 994b7bf..672cdc3 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,7 @@
"resolve-url-loader": "^3.1.1",
"sass": "^1.26.3",
"sass-loader": "^9.0.3",
- "sdf-2d": "^0.1.0-alpha",
+ "sdf-2d": "^0.1.2-alpha",
"source-map-loader": "^1.1.0",
"svg-url-loader": "^6.0.0",
"terser-webpack-plugin": "^2.3.8",
diff --git a/src/index.html b/src/index.html
index 5bd02e6..696b476 100644
--- a/src/index.html
+++ b/src/index.html
@@ -28,7 +28,7 @@
-
+
diff --git a/src/index.ts b/src/index.ts
index 41012d1..1d78dca 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -30,11 +30,17 @@ const overlay = document.querySelector('#overlay') as HTMLDivElement;
let textVisible = false;
const handleTextToggle = () => {
- [info, overlay, errors].forEach(
- (e) => (e.style.visibility = textVisible ? 'hidden' : 'inherit')
- );
textVisible = !textVisible;
+
+ [info, overlay, errors].forEach(
+ (e) => (e.style.visibility = textVisible ? 'inherit' : 'hidden')
+ );
toggleButton.innerHTML = textVisible ? 'Hide text' : 'Show text';
+ if (textVisible) {
+ toggleButton.classList.remove('off');
+ } else {
+ toggleButton.classList.add('off');
+ }
};
toggleButton.addEventListener('click', handleTextToggle);
handleTextToggle();
diff --git a/src/scenes/blob/blob.ts b/src/scenes/blob/blob.ts
index 703d547..417463a 100644
--- a/src/scenes/blob/blob.ts
+++ b/src/scenes/blob/blob.ts
@@ -5,14 +5,12 @@ export class Blob extends Drawable {
public static descriptor: DrawableDescriptor = {
sdf: {
shader: `
- uniform struct {
- vec2 headCenter;
- vec2 leftFootCenter;
- vec2 rightFootCenter;
- float headRadius;
- float footRadius;
- float k;
- }[BLOB_COUNT] blobs;
+ uniform vec2 headCenters[BLOB_COUNT];
+ uniform vec2 leftFootCenters[BLOB_COUNT];
+ uniform vec2 rightFootCenters[BLOB_COUNT];
+ uniform float headRadii[BLOB_COUNT];
+ uniform float footRadii[BLOB_COUNT];
+ //uniform float ks[BLOB_COUNT];
float smoothMin(float a, float b)
{
@@ -27,9 +25,9 @@ export class Blob extends Drawable {
void blobMinDistance(inout float minDistance, inout float color) {
for (int i = 0; i < BLOB_COUNT; i++) {
- float headDistance = circleDistance(blobs[i].headCenter, blobs[i].headRadius);
- float leftFootDistance = circleDistance(blobs[i].leftFootCenter, blobs[i].footRadius);
- float rightFootDistance = circleDistance(blobs[i].rightFootCenter, blobs[i].footRadius);
+ float headDistance = circleDistance(headCenters[i], headRadii[i]);
+ float leftFootDistance = circleDistance(leftFootCenters[i], footRadii[i]);
+ float rightFootDistance = circleDistance(rightFootCenters[i], footRadii[i]);
float res = min(
smoothMin(headDistance, leftFootDistance),
@@ -43,7 +41,13 @@ export class Blob extends Drawable {
`,
distanceFunctionName: 'blobMinDistance',
},
- uniformName: 'blobs',
+ propertyUniformMapping: {
+ footRadius: 'footRadii',
+ headRadius: 'headRadii',
+ rightFootCenter: 'rightFootCenters',
+ leftFootCenter: 'leftFootCenters',
+ headCenter: 'headCenters',
+ },
uniformCountMacroName: 'BLOB_COUNT',
shaderCombinationSteps: [1],
empty: new Blob(vec2.fromValues(0, 0)),
diff --git a/src/scenes/rain/rain-scene.ts b/src/scenes/rain/rain-scene.ts
index 82f5374..cb9aae0 100644
--- a/src/scenes/rain/rain-scene.ts
+++ b/src/scenes/rain/rain-scene.ts
@@ -37,7 +37,7 @@ export class RainScene implements Scene {
this.renderer.setRuntimeSettings({
ambientLight: vec3.fromValues(0.2, 0.2, 0.2),
- tileMultiplier: 10,
+ tileMultiplier: 8,
});
for (let i = 0; i < (canvas.getBoundingClientRect().width / 1000) * 20; i++) {
diff --git a/src/styles/index.scss b/src/styles/index.scss
index 3f3f1a9..b53c938 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -84,9 +84,15 @@ body {
cursor: pointer;
padding: 0.2em 0.5rem;
background: none;
+ user-select: none;
+
+ &.off:not(:hover) {
+ opacity: 0.5;
+ }
+ transition: opacity 200ms;
@media (max-width: $breakpoint) {
- width: 80px;
+ width: 90px;
}
}