feat: std.textureSampleGrad (+ docs: POM example)#2366
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:
📋 All resultsClick to reveal the results table (350 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
There was a problem hiding this comment.
Pull request overview
Adds a new Parallax Occlusion Mapping (POM) rendering example to the TypeGPU docs site, and introduces the missing std.textureSampleGrad stdlib binding needed by the example’s gradient-based texture sampling.
Changes:
- Add
textureSampleGradtotypegpu/std(CPU stub + WGSL codegen + barrel export). - Introduce a new docs example at
rendering/pom(types, shaders, runtime, meta, and canvas HTML). - Add new POM material texture assets under
apps/typegpu-docs/public/assets/pom/**.
Reviewed changes
Copilot reviewed 7 out of 44 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/src/std/texture.ts | Adds textureSampleGrad dualImpl + overload typings. |
| packages/typegpu/src/std/index.ts | Re-exports textureSampleGrad from the std barrel. |
| apps/typegpu-docs/src/examples/rendering/pom/types.ts | Defines vertex/params schemas, constants, and helpers for the POM example. |
| apps/typegpu-docs/src/examples/rendering/pom/shaders.ts | Adds PBR helper functions and POM math helpers used by the fragment shader. |
| apps/typegpu-docs/src/examples/rendering/pom/meta.json | Registers the example in the docs gallery (title/category/tags/coolFactor). |
| apps/typegpu-docs/src/examples/rendering/pom/index.ts | Implements the interactive POM demo: texture loading, ray-march shading, controls, resize handling, cleanup. |
| apps/typegpu-docs/src/examples/rendering/pom/index.html | Provides the canvas container for the example. |
| apps/typegpu-docs/public/assets/pom/** | Adds new texture assets used by the POM materials. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
iwoplaza
left a comment
There was a problem hiding this comment.
Let's gooo! 🧱
Left just a handful of nits
|
|
||
| const prevGap = prevSurfaceDepth - prevDepth; | ||
| const currGap = surfaceDepth - depth; | ||
| const t = std.clamp(prevGap / (prevGap - currGap), 0, 1); |
There was a problem hiding this comment.
| const t = std.clamp(prevGap / (prevGap - currGap), 0, 1); | |
| const t = std.saturate(prevGap / (prevGap - currGap)); |
| shadowFactor = std.min(shadowFactor, (softShadowMultiplier * gap) / marchedDepth); | ||
| } | ||
|
|
||
| shadowFactor = std.clamp(shadowFactor, 0, 1); |
There was a problem hiding this comment.
| shadowFactor = std.clamp(shadowFactor, 0, 1); | |
| shadowFactor = std.saturate(shadowFactor); |
There was a problem hiding this comment.
Could you pick a more... pleasing material? 🙏 💩
No description provided.