Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)7.2k · #13466

shaders-cursor-ripples

Skill này làm gì

Skill này thêm một biến dạng gợn nước WebGPU theo chuột trên một bức ảnh hoặc ảnh hero. Phù hợp với lập trình viên front end muốn một ảnh tương tác mượt mà mà không phải thiết kế lại trang.

Khi nào nên dùng

  • ✓Khi một ảnh hero hoặc ảnh thư viện cần hiệu ứng gợn nước theo chuột.
  • ✓Khi bạn muốn thay một hiệu ứng đèn soi cũ hơn trên ảnh.
  • ✓Khi bạn chỉ muốn tương tác shader từ một tham chiếu, không sao chép thiết kế của nó.

Liên kết skill

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/shaders-cursor-ripples/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/shaders-cursor-ripples/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi muốn ảnh trong phần hero của mình hiện gợn nước theo chuột, mà không thay đổi phần còn lại của trang.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent giữ ảnh và nội dung hiện có, đặt một canvas shader lên trên ảnh, rồi thêm lớp gợn nước phía trên. Agent gỡ bỏ mã con trỏ tùy chỉnh cũ và quay về ảnh thường khi chuyển động bị giảm hoặc WebGPU không khả dụng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Shaders Cursor Ripples

Core Contract

  1. Preserve the existing page, content, and semantic image.
  2. Install shaders and import from the active framework subpath.
  3. Render the source image through one Shader canvas.
  4. Place CursorRipples after ImageTexture so it post-processes that image.
  5. Keep toneMapping="aces" on the root.
  6. Let Shaders track the cursor. Remove custom spotlight coordinates, radial masks, duplicated reveal images, and pointer animation loops.
  7. Keep one real image beneath the canvas as the accessible loading and WebGPU fallback.
  8. Disable the shader for reduced motion and unsupported WebGPU.
  9. Lazy-load the shader code so the library does not inflate the initial page bundle.

When the user asks for only the shader effect, do not copy a reference's ribbon, blob, glow, typography, layout, copy, colors, or identity. Do not substitute the Shaders Water component: CursorRipples is the interactive image-displacement effect.

Inspect Before Editing

  • Find the real media wrapper, image URL, crop, overlays, z-index, and existing motion.
  • Confirm the wrapper has a non-zero rendered width and height.
  • Search for old reveal code such as data-reveal-hover, mask-image: radial-gradient, duplicated images, requestAnimationFrame, and manual pointer listeners.
  • Preserve unrelated parallax or entrance motion unless it conflicts with the shader canvas.
  • Check the installed shaders version and current framework API when the package may have changed.

Install

npm install shaders

Import from shaders/react, shaders/vue, shaders/svelte, or shaders/solid. For Vite projects, never add shaders to optimizeDeps.exclude; its CommonJS dependencies need Vite pre-bundling. No optimizeDeps entry is normally required.

Before a commercial release, verify the current Shaders license terms.

Required Composition

Keep the component order and values below:

<Shader toneMapping="aces">
  <ImageTexture url={imageUrl} objectFit="cover" />
  <CursorRipples decay={7.3} radius={0.6} />
</Shader>

Use this as the baseline before tuning intensity, chromaticSplit, or edges. Do not add SolidColor, Blob, Form3D, GaborNoise, Glow, or another generator unless the user explicitly requests the reference's generated artwork.

For React, copy and adapt assets/react/cursor-ripple-shader.tsx and assets/react/cursor-ripple-media.css.

Client and Fallback Pattern

Mount the shader only after the browser confirms WebGPU and motion is allowed:

const CursorRippleShader = lazy(() => import("./cursor-ripple-shader"));

const [shaderEnabled, setShaderEnabled] = useState(false);
const [shaderReady, setShaderReady] = useState(false);

useEffect(() => {
  const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)");

  const sync = () => {
    const enabled = "gpu" in navigator && !reduceMotion.matches;
    setShaderEnabled(enabled);
    if (!enabled) setShaderReady(false);
  };

  sync();
  reduceMotion.addEventListener("change", sync);
  return () => reduceMotion.removeEventListener("change", sync);
}, []);

Keep the semantic image in the wrapper, then overlay the lazy shader:

<figure className="cursor-ripple-media">
  <img
    className="cursor-ripple-media__fallback"
    src={imageUrl}
    alt={meaningfulAlt}
    width={width}
    height={height}
  />

  {shaderEnabled ? (
    <Suspense fallback={null}>
      <CursorRippleShader
        imageUrl={imageUrl}
        ready={shaderReady}
        onReady={() => setShaderReady(true)}
      />
    </Suspense>
  ) : null}
</figure>

For Next.js, an ssr: false dynamic import is also valid. Do not hide the fallback until the shader calls onReady; a failed WebGPU initialization must leave the page legible and complete.

Layering Rules

  • Give the media wrapper position: relative, a definite size, overflow: hidden, and isolation: isolate.
  • Keep the fallback at z-index 0 and the canvas at z-index 1.
  • Fill the wrapper with position: absolute; inset: 0; width: 100%; height: 100%.
  • Set the shader layer to pointer-events: none; Shaders listens globally and converts pointer coordinates using the canvas bounds.
  • Mark the shader wrapper aria-hidden="true"; the fallback image owns the accessible name.
  • Place copy, links, and controls above the canvas so the effect never intercepts i
Câu hỏi thường gặp

Nếu trình duyệt không hỗ trợ WebGPU thì sao?

Skill nói giữ một ảnh thật bên dưới canvas làm phương án dự phòng, để trang vẫn đúng.

Có làm nặng thêm trang không?

Skill nói nên tải lười mã shader để nó không làm chậm lần tải trang đầu tiên.

Có đổi thương hiệu hoặc nội dung không?

Không. Skill giữ nguyên trang, nội dung và ảnh ngữ nghĩa của bạn.

Chi tiết

Mô tả gốc của tác giả

Add cursor-following fluid WebGPU distortion over an existing image with the Shaders library's ImageTexture and CursorRipples components. Use when a hero, gallery, or media panel needs a water-ripple mouse effect; when replacing a drifting CSS spotlight or flashlight reveal; or when a prompt says to borrow only the shader interaction from a Shaders.com reference while preserving the current brand, image, copy, and layout.

repo: MengTo/Skills

Độ phổ biến

Sao GitHub
7.2k
Vị trí xếp hạng
#13466
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự