In This Article (7 sections)
How Jarl Builds and Renders Procedural 2D Grass With GPU Compute
Jarl’s procedural grass system starts from a different assumption than a conventional mesh or sprite solution. Instead of storing thousands of individual grass objects, the renderer treats the visible field as an image that can be reconstructed every frame. Environmental inputs such as a density map, wind and creature velocity fields, floor masks, blue noise, camera information, and artistic parameters are sent to the GPU, which determines where grass grows, generates deterministic blade properties, bends the blades, resolves overlapping pixels, and produces the final grass image.
This approach is particularly well suited to Jarl’s pixel-art scale. A blade is only a few pixels wide and a few dozen pixels tall before half-resolution rendering is considered, so representing it as a mathematically generated column of pixels can communicate its form without building triangles, instance transforms, or persistent blade buffers. Terrain controls whether grass is present, while deterministic hashing determines the individual blade arrangement. The same world tile and blade index always generate the same root position, height, variation, phase, and other properties, preventing grass from flickering or changing identity each frame.
WebGPU compute shaders make this reconstruction highly parallel. The first WGSL pass, represented by grass_generate.wgsl, performs the irregular generation work. An 8 by 8 workgroup supplies 64 invocations associated with a 16 by 16 screen region. The shader determines which world tiles can contribute grass to that region, expands the search area to account for blade height, thickness, density offset, and maximum sway, then distributes candidate blades among the workgroup threads. Each accepted blade receives deterministic attributes from a PCG-style hash, samples wind and creature movement at its root, and bends progressively from root to tip using a cubic height term so that the lower blade remains relatively stable while the tip moves more freely.
Blade roots and heights can be snapped to configurable pixel intervals to preserve the intended pixel-art appearance. Density is controlled through a world-aligned texture and can be varied further with value noise, while blue-noise culling removes selected candidates without creating obvious clusters or holes. Because the random decisions are anchored to world coordinates rather than screen coordinates, moving the camera changes which terrain is visible without causing the grass arrangement or stochastic edge decisions to crawl across the ground.
The first pass packs visible blade information into a 32-bit unsigned integer. The upper 16 bits contain blade-root depth, the next eight bits contain normalized root-to-tip height, and the final eight contain color variation. Multiple blades can attempt to cover the same pixel, so the shader uses atomicMax to select the highest-priority packed value. In Jarl’s top-down perspective, a larger root screen Y represents a blade closer to the camera, so placing depth in the most significant bits means the numerically largest integer normally represents the frontmost blade. The same comparison also preserves height and variation data for the winning sample.
The second compute pass, represented by grass_unpack.wgsl, converts those packed integers into grass color and depth textures. Each pixel is processed alongside its four cardinal neighbors, allowing the shader to estimate local coverage without using a large filtering kernel. Normalized blade height controls a darker root to brighter tip gradient, restrained variation prevents nearby blades from looking identical, and a subtle hue shift warms the upper areas. Neighbor information can also create partially covered support pixels around thin edges, with blue noise deciding which weak samples survive. This softens obvious raster gaps without making the grass look like smooth vector artwork.
The result is separated into a color texture and a root-depth texture. Alpha remains available for coverage and blending, while depth retains the information needed to place the grass correctly against sprites and walls. Jarl can therefore regenerate its visible grass every frame without maintaining a permanent database of blades, while still producing stable individual plants, environmental interaction, and consistent scene depth.

How Density, Wind, Interaction, and Compositing Make Jarl’s Grass Feel Part of the World
Jarl’s grass is procedural, but it is not detached from the rest of the environment. The density texture determines where vegetation can exist and how much can be generated in a region. Because it is aligned with world tiles rather than the viewport, changing the camera does not move the grass relative to the terrain. Building a floor or changing an environmental region can modify the inputs rather than requiring individual grass objects to be created or deleted.
The floor mask is especially important for construction and environmental boundaries. Player-built surfaces, rugs, stone areas, or other designated floor elements can be rendered into an offscreen texture. The grass generation or unpack process checks that mask using the blade’s root position. A blade rooted on a floor is suppressed, while one rooted in nearby soil can still lean over the edge. Testing the root rather than every blade pixel preserves natural overlap around borders.
Wind and creature interaction use vector fields instead of persistent per-blade simulation. The climate system supplies directional wind information over a coarse spatial grid, and every regenerated blade samples that field at its root. Deterministic phase and frequency variation prevents the meadow from moving as one synchronized block. The shader combines multiple oscillatory components with a directional lean, while taller blades receive greater compliance than short tufts.
Moving creatures contribute to a separate velocity field. Their movement is deposited into that field and gradually decays. Nearby grass samples the local direction and magnitude and bends accordingly, producing temporary wakes or disturbed vegetation without storing a bent angle or collision history on every blade. A smooth low-speed fade prevents abrupt snapping as the interaction dies away, while an exponential response keeps stronger movement from producing unbounded displacement.
Strong bending creates a separate rasterization problem. Consecutive blade rows can move more than one screen pixel apart near the tip, leaving the mathematically continuous blade visually broken into dashes. Jarl addresses this by storing the previous rasterized point and measuring the largest change along either screen axis. When the movement exceeds one pixel, the shader inserts interpolated samples between the two positions, effectively using an L-infinity digital differential approach. Normalized blade height is interpolated along those extra samples so shading remains continuous. Upright blades incur almost no additional work because extra pixels are emitted only when the bend would otherwise create a visible gap.
Grass composition then places these generated pixels correctly among characters, walls, lighting, and fog. Jarl does not simply render the grass beneath or above the entire scene. Its compositor receives grass color and root depth along with sprite, wall, and height information. Sprite pixels include height above their contact point, allowing the renderer to reconstruct the effective feet line used for top-down ordering. Wall positions are similarly converted into consistent tile-aligned depth references.
The grass root depth can then determine whether a visible blade pixel belongs behind both wall and character, above a wall but behind a character, or in front of both. This is important because the blade’s tip position alone would produce incorrect ordering. A tall blade may visually rise behind a character’s torso while its lower portion should still cover the character’s feet. Root-based depth preserves that relationship.
Lighting and atmosphere are incorporated during composition as well. Grass receives floor irradiance from the global illumination system, allowing it to respond to environmental lighting rather than appearing as a separately colored overlay. Fog is applied consistently with other scene elements, including height-aware treatment that lets taller blade tips rise above denser ground fog. Ground shadowing beneath thick vegetation helps connect the generated image visually to the terrain.
The same design philosophy applies to navigation and interaction throughout the system: environmental fields describe large-scale conditions, deterministic generation creates local detail, and the compositor integrates the result with the world. Individual blades do not need persistent identities in memory for the meadow to appear stable and responsive.

How Bevy, wgpu, and GPU Optimizations Keep Jarl’s Procedural Grass Efficient
Jarl runs on a customized Bevy-based engine with wgpu providing the low-level graphics foundation. This architecture allows the game to create custom compute pipelines while still using the engine’s resource management and scheduling systems. CPU-side code prepares the density, wind, velocity, floor-mask, blue-noise, camera, uniform, storage-buffer, and output resources. The rendering schedule then clears the atomic target, dispatches the generation shader, runs the unpack pass, and provides the resulting textures to the compositor.
wgpu follows concepts closely related to WebGPU, including WGSL shaders and bind-group-based resource organization, while targeting modern native graphics backends such as Vulkan, Direct3D, and Metal. That similarity also made it practical for the developers to build an interactive browser demonstration using related WebGPU shader code. The browser version and production renderer are not identical benchmarks, but they share enough architecture for the demonstration to expose the underlying technique clearly.
Performance work concentrated on the first compute pass because profiling showed that scattered atomic writes were the main expense. A null-shader comparison, where dispatch work remained but writes were removed, indicated that the generation cost was dominated by output traffic rather than purely by arithmetic. Several optimizations therefore focused on reducing unnecessary blade samples and distributing the remaining work more effectively.
One important change was cooperative dispatch. An earlier design effectively assigned an entire world tile’s blade generation to one thread, causing dense tiles to keep a single invocation busy while neighboring threads did little. The later design spreads candidate indices across the 64 invocations of an 8 by 8 workgroup. In the tested full-density configuration, the developers reported roughly a fourfold improvement from this restructuring.
Blade caps also prevent extreme density values from creating large amounts of invisible work. In dense vegetation, many samples ultimately lose the atomicMax comparison because another blade is already closer. Generating still more hidden blades raises atomic traffic without necessarily producing a visible improvement, so limiting candidate counts can preserve the appearance while controlling worst-case cost.
Half-resolution rendering delivered one of the largest practical gains. Rendering at half the width and height reduces the number of output pixels to one quarter, while blade dimensions also become smaller in the reduced-resolution target and therefore require fewer writes. Because the grass is intentionally low-detail pixel-art content, scaling the completed image during composition preserves its visual character better than this technique would for fine text or highly detailed graphics.
Blue-noise culling provides another scalable reduction. Candidate blades can be rejected before rasterization according to a world-anchored blue-noise threshold. In thick grass, overlap conceals much of the lost density, while blue noise distributes the surviving blades more evenly than independent white-noise rejection. This reduces atomic work without creating conspicuous empty patches or repetitive clumps.
Not every attempted optimization improved performance. Moving more information into workgroup memory produced a regression in the measured implementation, likely because the additional storage pressure introduced spilling without addressing the real bottleneck. Reading a destination pixel before calling atomicMax was also slower because the extra memory operation cost more than it saved when most thin-blade pixels had relatively little contention. These results demonstrate why GPU optimization must be based on profiling rather than assumptions about which source-code operation appears cheaper.
The algorithm still has limits. Its cost rises with output resolution, visible density, blade dimensions, and the number of atomic emissions. A close camera makes blades larger on screen and is consequently more expensive than the game’s normal presentation. Atomic throughput also varies by GPU architecture, so the balance of optimizations can change across hardware.
Within Jarl’s intended visual scale, however, the combination of deterministic generation, cooperative compute work, atomic depth selection, half-resolution rendering, blue-noise culling, and field-based interaction allows large amounts of grass to exist without persistent blade geometry. The system demonstrates how a pixel-art renderer can use modern GPU compute techniques not merely to imitate conventional 3D vegetation, but to build a grass solution specifically around the requirements of a top-down 2D visual style.

Frequently Asked Questions (FAQs)
- What is Jarl’s procedural 2D grass system?
Jarl’s procedural 2D grass system is a GPU driven renderer that rebuilds the visible grass every frame instead of storing thousands of individual blades as objects. A compute shader generates and bends deterministic blades, resolves which blade owns each covered pixel, and stores the result in an atomic buffer. A second compute shader shades those winning pixels before the compositor places the grass correctly around walls, characters, lighting, and other scene elements. - Does Jarl use meshes for each grass blade?
No. The published technique treats the grass as a generated screen image rather than a collection of individual meshes, sprites, or scene entities. Each blade exists only temporarily as calculations inside the compute shader before its visible pixels are written into the output. This removes the need to permanently store positions, transforms, animation states, or geometry for every blade in the field. - Why does the grass not change position every frame?
Each blade is generated from a deterministic hash based on stable world tile coordinates and its candidate blade index. Because the same inputs always produce the same root position, height, variation, phase, and other properties, the layout can be regenerated every frame without randomly changing. Wind and creature interaction still move the blades dynamically, but their underlying positions remain attached to the same locations in the world. - What does the
atomicMaxoperation do?atomicMaxresolves situations where several grass blades attempt to write to the same output pixel at the same time. Each candidate writes a packed 32 bit integer, and the operation keeps whichever value is numerically larger. Because blade root depth occupies the most significant bits, the comparison effectively acts as a software depth test while also retaining the winning blade’s height and color variation information. - What information is stored in each packed grass pixel?
The packed 32 bit value contains three pieces of information needed by the second compute pass. The upper 16 bits store the blade’s root screen depth, the next eight bits represent the current normalized position from the root toward the tip, and the final eight bits contain per blade variation used for subtle visual differences. A packed value of zero indicates that no grass sample won that pixel. - How does grass react when a creature moves through it?
Moving creatures deposit their motion into an entity velocity field covering the surrounding world. When grass is regenerated, each blade samples that field at its root and combines the resulting movement with the environmental wind direction. Nearby blades then bend according to the creature’s movement, creating a temporary wake that gradually disappears as the stored velocity field decays. - How are floors kept free of grass?
Floor surfaces, rugs, and other areas where vegetation should not grow are rendered into a separate mask texture. The grass system checks this mask using each blade’s root position and removes the blade when that root lies on a covered surface. Checking only the root is important because it still allows grass growing in nearby soil to bend naturally over the edge of a path or floor. - Why is the grass rendered at half resolution?
Rendering at half resolution reduces both width and height by half, leaving only one quarter as many output pixels to process. It also means individual blades require fewer pixel rows and fewer atomic writes, which reduces one of the most expensive parts of the generation pass. Because Jarl deliberately uses a low resolution pixel art style, scaling the completed grass back into the scene preserves the intended appearance while providing a substantial performance improvement. - Can the Jarl grass shaders run in a browser?
Yes. The official interactive demonstration uses WebGPU to execute related WGSL compute shaders directly in compatible browsers. Whether it works depends on the browser, operating system, GPU support, security context, and WebGPU configuration. For systems where WebGPU is unavailable, the technical article also provides a captured version so the effect can still be viewed. - Are the complete WGSL shaders publicly viewable?
Yes. The technical demonstration publishes complete versions ofgrass_generate.wgslandgrass_unpack.wgsl. Developers can inspect how blade candidates are generated, how deterministic randomness and environmental fields are sampled, howatomicMaxresolves overlapping grass pixels, and how the second pass handles shading, edge treatment, floor masking, and the final color and depth outputs.

Conclusion
Building procedural 2D grass with GPU compute in Jarl (WebGPU) shows how a renderer can exchange persistent scene complexity for deterministic GPU reconstruction. The system needs only compact world aligned inputs, a parameter block, two compute passes, an atomic storage buffer, and a compositor capable of understanding blade root depth.
The first pass turns terrain density and stable hashes into animated blades. World space wind and creature velocity provide dynamic movement without requiring per-blade state. Packed integers and atomicMax resolve overlap while carrying enough information for later shading. The second pass converts those winners into a stylized grass image with gradients, restrained color variation, stochastic edge processing, and separate depth output.
The compositor is what ultimately makes the technique convincing. By comparing blade root depth against object feet and wall references, Jarl can place grass behind a character’s upper body while allowing lower blades to overlap the character’s boots. Global illumination, shadows, and fog then connect the generated image to the rest of the environment.
Performance comes from understanding where the work occurs. Cooperative dispatch balances dense tiles, blade caps prevent invisible overdraw, blue noise culling removes redundant candidates, and half resolution rendering sharply reduces atomic traffic. Row bridging solves continuity problems when strong bending causes the procedural curve to move more than one pixel between samples.
The broader lesson is not that every 2D game should abandon sprites or geometry. Jarl’s method works because it matches the needs of a top down, pixel art world filled with vegetation. It is a focused example of how compute shaders, deterministic procedural generation, software rasterization, and scene aware composition can combine into a responsive environmental effect.
Sources and Citations
- Jarl Devs Team, August 10, 2026, 2D Grass Rendering with WebGPU Compute Shaders: Explains the two-pass rendering pipeline, atomic depth buffer and optimization techniques.
https://jarl-game.com/blog/2d-gpu-grass-rendering/ - Jarl, grass_generate.wgsl: Provides the generation shader for blade rasterization, hashing, wind response and atomic writes.
https://jarl-game.com/shaders/grass_generate.wgsl - Jarl, grass_unpack.wgsl: Provides the unpack shader for shading, gap filling, floor masking and depth output.
https://jarl-game.com/shaders/grass_unpack.wgsl - World Wide Web Consortium, WebGPU Shading Language: Defines WGSL compute shaders, atomic operations and atomicMax behavior.
https://www.w3.org/TR/WGSL/ - MDN Web Docs, WebGPU API: Explains GPU computing capabilities, security requirements and browser compatibility.
https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API - Bevy Foundation, May 17, 2023, Bevy + WebGPU: Explains Bevy’s wgpu architecture, WGSL integration and graphics backend support.
https://bevy.org/news/bevy-webgpu/ - Mark Jarzynski and Marc Olano, 2020, Hash Functions for GPU Rendering: Evaluates GPU hash functions, PCG hashing, statistical quality and computational performance.
https://jcgt.org/published/0009/03/02/ - Christoph Peters, December 22, 2016, Free Blue Noise Textures: Explains blue-noise properties and provides freely licensed textures.
https://www.momentsingraphics.de/BlueNoise.html - NVIDIA Technical Blog, December 17, 2021, Rendering in Real Time with Spatiotemporal Blue Noise Textures, Part 1: Explains blue-noise sampling, spatial distribution and stochastic transparency.
https://developer.nvidia.com/blog/rendering-in-real-time-with-spatiotemporal-blue-noise-textures-part-1/ - 80 Level, August 12, 2026, Building Procedural 2D Grass With GPU Compute: Covers Jarl’s procedural grass rendering, interactive demonstration and performance results.
https://80.lv/articles/building-procedural-2d-grass-with-gpu-compute
Recommendations
- Castlevania: Belmont’s Curse is a New Castlevania Game Coming in 2026 — Release Date, Trailer, Platforms, Story & Gameplay
- Starsand Island Hits Game Pass August 20, 2026: Release Date, Features, Platforms and What to Expect
- 3D Rendering Services: Buyer’s Guide to Pricing, Quality & Turnaround for Animation, VFX & Real-Time Games
- Chinese Esports Host Accused of Blackface Following On-Stream Stunt at Naraka: Bladepoint NBPL 2026
- Blackwood Gameplay Deep Dive Explains Its Guns, Combat System, and Cinematic Action
- OpenAI’s Advertising Business Could Miss Its Revenue Forecast by 90%
- Former Xbox Front Man Major Nelson Joins Commodore’s Retro Revival: What It Means for the Commodore 64 Comeback
- Sony PlayStation Disc Re-Order Clarification Explained
- Why Hearthstone Still Isn’t on Consoles: Blizzard’s Latest Explanation, Real Barriers, and What Could Change
- Ghost of Yotei Tourism Boom: How Hokkaido Towns Hope the Hit PS5 Game Will Boost Visitors















































































































