diff --git a/components/content/array-cameras/KnightRigged.vue b/components/content/array-cameras/KnightRigged.vue index 52d1dc46..bbb1dfed 100644 --- a/components/content/array-cameras/KnightRigged.vue +++ b/components/content/array-cameras/KnightRigged.vue @@ -5,14 +5,11 @@ const { nodes, state } = useGLTF( 'https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/warcraft-3-alliance-footmanfanmade/source/Footman_RIG.glb', ) -watch(nodes, (newState) => { - console.log(newState) -}) const model = computed(() => nodes.value.Footman_rig) const animations = computed(() => state.value?.animations || []) -const { actions } = useAnimations(animations, model) +const { actions } = useAnimations(animations, model as TresObject) const currentAction = ref() diff --git a/components/content/dancing-blob/TheDancingBlob.vue b/components/content/dancing-blob/TheDancingBlob.vue index 712086a6..4cc2a85b 100644 --- a/components/content/dancing-blob/TheDancingBlob.vue +++ b/components/content/dancing-blob/TheDancingBlob.vue @@ -1,19 +1,20 @@ - - \ No newline at end of file diff --git a/components/content/github-stars/index.vue b/components/content/github-stars/index.vue deleted file mode 100644 index ad6ed916..00000000 --- a/components/content/github-stars/index.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - \ No newline at end of file diff --git a/components/content/magical-marbles/Marble.vue b/components/content/magical-marbles/Marble.vue new file mode 100644 index 00000000..1b5f83b8 --- /dev/null +++ b/components/content/magical-marbles/Marble.vue @@ -0,0 +1,182 @@ + + + diff --git a/components/content/magical-marbles/index.vue b/components/content/magical-marbles/index.vue index 6f98ecec..b279af3a 100644 --- a/components/content/magical-marbles/index.vue +++ b/components/content/magical-marbles/index.vue @@ -1,131 +1,133 @@ \ No newline at end of file + diff --git a/components/content/magical-marbles/shaders.ts b/components/content/magical-marbles/shaders.ts index 9c4d4c94..68bc3f87 100644 --- a/components/content/magical-marbles/shaders.ts +++ b/components/content/magical-marbles/shaders.ts @@ -5,80 +5,72 @@ export const vertex = /* glsl */ ` void main() { v_pos = position; v_dir = position - cameraPosition; // Points from camera to vertex - - // csm_Position = position; } ` export const fragment = /* glsl */ ` - #define FLIP vec2(1., -1.) - - uniform vec3 colorA; - uniform vec3 colorB; - uniform sampler2D heightMap; - uniform sampler2D displacementMap; - uniform int iterations; - uniform float depth; - uniform float smoothing; - uniform float displacement; - uniform float time; - - varying vec3 v_pos; - varying vec3 v_dir; - - /** - * @param p - Point to displace - * @param strength - How much the map can displace the point - * @returns Point with scrolling displacement applied - */ - vec3 displacePoint(vec3 p, float strength) { - vec2 uv = equirectUv(normalize(p)); - vec2 scroll = vec2(time, 0.); - vec3 displacementA = texture(displacementMap, uv + scroll).rgb; // Upright - vec3 displacementB = texture(displacementMap, uv * FLIP - scroll).rgb; // Upside down - - // Center the range to [-0.5, 0.5], note the range of their sum is [-1, 1] - displacementA -= 0.5; - displacementB -= 0.5; - - return p + strength * (displacementA + displacementB); - } - - /** - * @param rayOrigin - Point on sphere - * @param rayDir - Normalized ray direction - * @returns Diffuse RGB color - */ - vec3 marchMarble(vec3 rayOrigin, vec3 rayDir) { - float perIteration = 1. / float(iterations); - vec3 deltaRay = rayDir * perIteration * depth; - - // Start at point of intersection and accumulate volume - vec3 p = rayOrigin; - float totalVolume = 0.; - - for (int i=0; i= iterations) break; + + vec3 displaced = displacePoint(p, displacement); + vec2 uv = getUv(displaced); + float heightMapVal = texture(heightMap, uv).r; + + float height = length(p); + float cutoff = 1.0 - float(i) * invIterations; + float slice = smoothstep(cutoff, cutoff + smoothing, heightMapVal); + + totalVolume += slice * invIterations; + p += deltaRay; + } + + return mix(colorA, colorB, totalVolume); +} + +void main() { + vec3 rayDir = normalize(v_dir); + vec3 rayOrigin = v_pos; + + vec3 rgb = marchMarble(rayOrigin, rayDir); + csm_DiffuseColor = vec4(rgb, 1.0); +} +` diff --git a/components/content/materials/MaterialSphere.vue b/components/content/materials/MaterialSphere.vue deleted file mode 100644 index f206fdc8..00000000 --- a/components/content/materials/MaterialSphere.vue +++ /dev/null @@ -1,105 +0,0 @@ - - - diff --git a/components/content/materials/index.vue b/components/content/materials/index.vue deleted file mode 100644 index b74e48ee..00000000 --- a/components/content/materials/index.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/content/experiments/magical-marbles.md b/content/experiments/magical-marbles.md new file mode 100644 index 00000000..3ee8f75e --- /dev/null +++ b/content/experiments/magical-marbles.md @@ -0,0 +1,10 @@ +--- +title: Magical Marbles +author: damienmontastier +description: Magical Marbles Sphere +tags: ['magical', 'marbles', 'sphere', 'shaders', 'glsl', 'contact shadow'] +date: 2024-02-28 +updated: 2025-06-29 +--- + + \ No newline at end of file diff --git a/nuxt.config.ts b/nuxt.config.ts index 6844acf0..154e2357 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -46,7 +46,7 @@ export default defineNuxtConfig({ '@nuxt/eslint', ], - css: ['/styles/main.css', '@tresjs/leches/styles'], + css: ['/styles/main.css'], declare: ['*.glsl'], tres: { diff --git a/package.json b/package.json index c1b17946..544d7805 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@tresjs/cientos": "5.0.0-next.4", "@tresjs/core": "5.0.0-next.6", "@tresjs/eslint-config-vue": "^0.2.1", - "@tresjs/leches": "https://pkg.pr.new/@tresjs/leches@5536ad5", + "@tresjs/leches": "https://pkg.pr.new/@tresjs/leches@f356fed", "@tresjs/nuxt": "4.1.0-next.1", "@tweakpane/plugin-essentials": "^0.2.1", "@types/three": "^0.177.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7af3abd3..43f41f09 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -73,8 +73,8 @@ importers: specifier: ^0.2.1 version: 0.2.1(@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@8.34.1(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1)(typescript@5.8.3))(eslint@8.57.1)(typescript@5.8.3) '@tresjs/leches': - specifier: https://pkg.pr.new/@tresjs/leches@5536ad5 - version: https://pkg.pr.new/@tresjs/leches@5536ad5(magicast@0.3.5)(unocss@66.2.3(@unocss/webpack@66.2.3(webpack@5.99.9(esbuild@0.25.5)))(postcss@8.5.6)(vite@6.3.5(@types/node@24.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.43.0)(yaml@2.8.0))(vue@3.5.17(typescript@5.8.3)))(vue@3.5.17(typescript@5.8.3)) + specifier: https://pkg.pr.new/@tresjs/leches@f356fed + version: https://pkg.pr.new/@tresjs/leches@f356fed(magicast@0.3.5)(unocss@66.2.3(@unocss/webpack@66.2.3(webpack@5.99.9(esbuild@0.25.5)))(postcss@8.5.6)(vite@6.3.5(@types/node@24.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.43.0)(yaml@2.8.0))(vue@3.5.17(typescript@5.8.3)))(vue@3.5.17(typescript@5.8.3)) '@tresjs/nuxt': specifier: 4.1.0-next.1 version: 4.1.0-next.1(jwt-decode@4.0.0)(magicast@0.3.5)(postcss@8.5.6)(rollup@4.43.0)(three@0.177.0)(typescript@5.8.3)(vite@6.3.5(@types/node@24.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.43.0)(yaml@2.8.0))(vue@3.5.17(typescript@5.8.3))(webpack@5.99.9(esbuild@0.25.5))(zod@3.25.67) @@ -1487,8 +1487,8 @@ packages: eslint: '>=7.4.0' typescript: '>=3.9' - '@tresjs/leches@https://pkg.pr.new/@tresjs/leches@5536ad5': - resolution: {tarball: https://pkg.pr.new/@tresjs/leches@5536ad5} + '@tresjs/leches@https://pkg.pr.new/@tresjs/leches@f356fed': + resolution: {tarball: https://pkg.pr.new/@tresjs/leches@f356fed} version: 0.14.1 peerDependencies: vue: '>=3.3.4' @@ -1750,12 +1750,12 @@ packages: '@unocss/core@65.5.0': resolution: {integrity: sha512-XYWdS09M2XOjZNDotGhI2TIW/6duLNiyssopwjCbv4AlPklF0bZI86SKI55syYDBt6GRadoQbuvUkhSiTV/hzQ==} - '@unocss/core@66.1.0-beta.7': - resolution: {integrity: sha512-l1/r+Jd9TbsRqR/geEdIV/Erzvs26GitTtMVsGcJfuaK1/WWOLtbSHRUDQAB/UpcOOWvuNuAv4UWsXX9Z0DFmw==} - '@unocss/core@66.2.3': resolution: {integrity: sha512-mRpwm3HUAqCtQrBB7+vkCp0qDZT+G1s2EAVJIF6zzrnoqb2BmIlHgz7DXVDufRFMRJtQUCp2jVMtEQZCTXEVjQ==} + '@unocss/core@66.3.2': + resolution: {integrity: sha512-C8UbTenNb/pHo68Ob+G1DTKJkQOeWT8IXTzDV7Vq6hPa9R7eE1l2l20pDKGs6gXYEBYPpY9EV4f5E0vUKDf8sw==} + '@unocss/extractor-arbitrary-variants@65.5.0': resolution: {integrity: sha512-7K3gftOdkv9jbWvbkExTcx6/FDP2Xk/NSsOYTvR9oITLnLjmdQvp+9276WSnNfKF3frBl8ZcqpkC2EsuL2Yutw==} @@ -9161,9 +9161,9 @@ snapshots: - eslint-import-resolver-webpack - supports-color - '@tresjs/leches@https://pkg.pr.new/@tresjs/leches@5536ad5(magicast@0.3.5)(unocss@66.2.3(@unocss/webpack@66.2.3(webpack@5.99.9(esbuild@0.25.5)))(postcss@8.5.6)(vite@6.3.5(@types/node@24.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.43.0)(yaml@2.8.0))(vue@3.5.17(typescript@5.8.3)))(vue@3.5.17(typescript@5.8.3))': + '@tresjs/leches@https://pkg.pr.new/@tresjs/leches@f356fed(magicast@0.3.5)(unocss@66.2.3(@unocss/webpack@66.2.3(webpack@5.99.9(esbuild@0.25.5)))(postcss@8.5.6)(vite@6.3.5(@types/node@24.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.43.0)(yaml@2.8.0))(vue@3.5.17(typescript@5.8.3)))(vue@3.5.17(typescript@5.8.3))': dependencies: - '@unocss/core': 66.1.0-beta.7 + '@unocss/core': 66.3.2 '@vueuse/components': 13.3.0(vue@3.5.17(typescript@5.8.3)) '@vueuse/motion': 3.0.3(magicast@0.3.5)(vue@3.5.17(typescript@5.8.3)) unocss-preset-scrollbar: 3.2.0(unocss@66.2.3(@unocss/webpack@66.2.3(webpack@5.99.9(esbuild@0.25.5)))(postcss@8.5.6)(vite@6.3.5(@types/node@24.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.43.0)(yaml@2.8.0))(vue@3.5.17(typescript@5.8.3))) @@ -9559,10 +9559,10 @@ snapshots: '@unocss/core@65.5.0': {} - '@unocss/core@66.1.0-beta.7': {} - '@unocss/core@66.2.3': {} + '@unocss/core@66.3.2': {} + '@unocss/extractor-arbitrary-variants@65.5.0': dependencies: '@unocss/core': 65.5.0 diff --git a/public/experiments/magical-marbles.png b/public/experiments/magical-marbles.png new file mode 100644 index 00000000..a9e7f612 Binary files /dev/null and b/public/experiments/magical-marbles.png differ