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.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
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
- Preserve the existing page, content, and semantic image.
- Install
shadersand import from the active framework subpath. - Render the source image through one
Shadercanvas. - Place
CursorRipplesafterImageTextureso it post-processes that image. - Keep
toneMapping="aces"on the root. - Let Shaders track the cursor. Remove custom spotlight coordinates, radial masks, duplicated reveal images, and pointer animation loops.
- Keep one real image beneath the canvas as the accessible loading and WebGPU fallback.
- Disable the shader for reduced motion and unsupported WebGPU.
- 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
shadersversion 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, andisolation: isolate. - Keep the fallback at z-index
0and the canvas at z-index1. - 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
Bình luận
- …
Thêm skill từ kho mã này
3d-cloth-material
7.2kGiúp agent của bạn tạo vải dệt 3D trông thật trong Three.js, với sợi dệt, ánh bóng nhẹ, nếp gấp tự nhiên, viền gấu và đường may.
3d-falling-leaves
7.2kGiúp agent của bạn thêm lá rơi chân thực vào cảnh 3D, với lá xoay tròn, trôi theo gió và được tái sử dụng khi máy quay di chuyển.
3d-four-seasons
7.2kGiúp agent của bạn thêm diện mạo xuân, hạ, thu, đông vào cảnh 3D, thay đổi cây cối, ánh sáng, bầu trời và tuyết mà không cần dựng lại cảnh.
3d-high-poly-models
7.2kGiúp agent của bạn dựng mô hình 3D chi tiết với hình dạng mượt và cạnh trông thật, rồi tạo các phiên bản nhẹ hơn chạy tốt trên web.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.