Download shaders.html from blackballs23/skyfeather-physics-simulator: direct link, hf CLI and curl.
- Browser
- Download file 6.31 kB
-
https://huggingface.co/spaces/blackballs23/skyfeather-physics-simulator/resolve/main/shaders.html
- Command line
-
hf download hf://spaces/blackballs23/skyfeather-physics-simulator/shaders.html
-
curl -L -o shaders.html https://huggingface.co/spaces/blackballs23/skyfeather-physics-simulator/resolve/main/shaders.html
6.31 kB
| <html lang="en" class="dark"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>AetherEngine Shader Documentation</title> | |
| <link rel="stylesheet" href="style.css"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script> | |
| <script>hljs.highlightAll();</script> | |
| </head> | |
| <body class="bg-gray-900 text-gray-100 min-h-screen"> | |
| <custom-navbar></custom-navbar> | |
| <main class="container mx-auto px-4 py-8 max-w-4xl"> | |
| <section class="mb-12"> | |
| <h1 class="text-4xl font-bold mb-4 bg-gradient-to-r from-primary-500 to-secondary-500 bg-clip-text text-transparent"> | |
| GPU Feather Simulation | |
| </h1> | |
| <p class="text-lg text-gray-300"> | |
| High-performance compute shader for realistic feather dynamics. | |
| </p> | |
| </section> | |
| <section class="mb-16 bg-gray-800 rounded-xl p-6"> | |
| <h2 class="text-2xl font-bold mb-6">BirdShaders.hlsl</h2> | |
| <pre class="bg-gray-900 p-4 rounded-lg overflow-x-auto"><code class="language-hlsl">// BirdShaders.hlsl — GPU Feather Simulation | |
| StructuredBuffer<float3> FeatherBasePositions; | |
| RWStructuredBuffer<float3> FeatherPoints; | |
| cbuffer FeatherParams { float WindStrength; float Flexibility; float Time; } | |
| [numthreads(256, 1, 1)] | |
| void main(uint3 id : SV_DispatchThreadID) | |
| { | |
| float3 base = FeatherBasePositions[id.x]; | |
| float3 p = FeatherPoints[id.x]; | |
| float wind = sin(Time * 3 + id.x * 0.1) * WindStrength; | |
| float curl = curlnoise(p * 0.25) * 0.3; | |
| // Feather bending = base anchor + wind deformation + curl turbulence | |
| p = lerp(base, p + float3(0, wind, curl), Flexibility); | |
| FeatherPoints[id.x] = p; | |
| }</code></pre> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6"> | |
| <div class="bg-gray-700 p-4 rounded-lg"> | |
| <h3 class="text-xl font-semibold mb-3 text-primary-500">Buffers</h3> | |
| <ul class="space-y-2"> | |
| <li><span class="font-mono text-yellow-300">FeatherBasePositions</span>: Original feather positions</li> | |
| <li><span class="font-mono text-yellow-300">FeatherPoints</span>: Current feather positions (RW)</li> | |
| <li><span class="font-mono text-yellow-300">FeatherParams</span>: Simulation parameters</li> | |
| </ul> | |
| </div> | |
| <div class="bg-gray-700 p-4 rounded-lg"> | |
| <h3 class="text-xl font-semibold mb-3 text-primary-500">Techniques</h3> | |
| <ul class="space-y-2"> | |
| <li>Compute shader with 256 threads</li> | |
| <li>Procedural wind animation</li> | |
| <li>Curl noise for turbulence</li> | |
| <li>Flexibility-based interpolation</li> | |
| </ul> | |
| </div> | |
| </div> | |
| </section> | |
| <section class="mb-16"> | |
| <h2 class="text-2xl font-bold mb-6">Shader Breakdown</h2> | |
| <div class="space-y-6"> | |
| <div class="bg-gray-800 p-6 rounded-xl"> | |
| <h3 class="text-xl font-semibold mb-3 text-primary-500">Thread Execution</h3> | |
| <p class="text-gray-300"> | |
| The shader runs 256 threads per dispatch, processing individual feather points in parallel. | |
| Each thread uses its <span class="font-mono text-yellow-300">SV_DispatchThreadID</span> to index into | |
| the structured buffers containing feather positions. | |
| </p> | |
| </div> | |
| <div class="bg-gray-800 p-6 rounded-xl"> | |
| <h3 class="text-xl font-semibold mb-3 text-primary-500">Wind Simulation</h3> | |
| <p class="text-gray-300"> | |
| Wind is simulated using a sine wave that varies over time and across different feathers. | |
| The <span class="font-mono text-yellow-300">WindStrength</span> parameter controls intensity while | |
| the phase offset (<span class="font-mono text-yellow-300">id.x * 0.1</span>) creates variation. | |
| </p> | |
| </div> | |
| <div class="bg-gray-800 p-6 rounded-xl"> | |
| <h3 class="text-xl font-semibold mb-3 text-primary-500">Curl Noise</h3> | |
| <p class="text-gray-300"> | |
| Curl noise generates divergence-free turbulence patterns ideal for fluid-like motion. | |
| The scaled result (<span class="font-mono text-yellow-300">0.3</span>) adds subtle, natural-looking | |
| perturbations to the feather movement. | |
| </p> | |
| </div> | |
| <div class="bg-gray-800 p-6 rounded-xl"> | |
| <h3 class="text-xl font-semibold mb-3 text-primary-500">Flexibility</h3> | |
| <p class="text-gray-300"> | |
| The <span class="font-mono text-yellow-300">Flexibility</span> parameter controls how much feathers | |
| deviate from their base positions. A lerp operation smoothly blends between anchored | |
| and dynamic states. | |
| </p> | |
| </div> | |
| </div> | |
| </section> | |
| <section> | |
| <h2 class="text-2xl font-bold mb-6">Visualization</h2> | |
| <div class="aspect-w-16 aspect-h-9 bg-gray-800 rounded-xl overflow-hidden"> | |
| <img src="http://static.photos/technology/1024x576/42" alt="Feather simulation visualization" class="w-full h-full object-cover"> | |
| </div> | |
| </section> | |
| </main> | |
| <custom-footer></custom-footer> | |
| <script src="components/navbar.js"></script> | |
| <script src="components/footer.js"></script> | |
| <script src="script.js"></script> | |
| <script>feather.replace();</script> | |
| </body> | |
| </html> |