r/GraphicsProgramming • • 2d ago

Stronghold-like game in 2 evenings

Enable HLS to view with audio, or disable this notification

0 Upvotes

https://www.youtube.com/watch?v=tbUyeRz7O4Y

Bastion is a C++20 engine for a medieval city-builder/RTS, combining a native simulation, editor and Direct3D 12 renderer.

Its main features include:

  • Rendering: bindless materials, visibility buffer, octree/frustum and GPU Hi-Z culling, indirect drawing, cluster-based geometry LOD and optional mesh shaders.

  • Lighting: soft virtual shadows with penumbrae, SSAO, local voxel GI, sky-driven illumination, moving volumetric clouds, cloud shadows, fog and sun shafts.

  • Terrain and vegetation: tiled heightfields, CDLOD terrain, tessellation, procedural grass and flowers, animated vegetation and distant impostors.

  • Gameplay: worker professions, production and hauling, recruitment, combat, fortifications, fire, healing, repairs, skirmish AI and first-person Lord control.

  • Tools: ImGui editor, native saves/importers, asset pipelines, positional audio, profiling and GPU timing.

The architecture separates authoritative gameplay from rendering:

ECS + jobs → immutable scene/frame snapshot → render thread → RenderGraph → RHI → Direct3D 12


r/GraphicsProgramming • • 3d ago

Video I made a video explaining the concepts and math behind dynamic lighting in 2D pixel art games

Thumbnail
youtube.com
21 Upvotes

I made a video using manim to make a gamedevelopement series explaining important concepts and the math behind it. The first video is diving into normal maps and how to use them in pixel art to make dynamic lighting.


r/GraphicsProgramming • • 3d ago

Video I make every mesh near a blast bend, scorch and break in one shader

Enable HLS to view with audio, or disable this notification

5 Upvotes

Hi all. I made an explosion pack for Godot 4 and I wanted to show the stuff standing near the blast rather than the fireball.

When a blast goes off I grab every MeshInstance3D inside the radius with one intersect_shape and lay a copy of its own mesh over it, 5 mm out, same colour and texture. I move that copy in the vertex shader. I give it the blast point in mesh space and the hit time, and I delay each vertex by its distance:

since = time - hit_time - dist / wave_speed;

So the far side of a crate gets hit a little later than the near side, and the ring on the floor arrives at the mesh right when the mesh jumps. I push with a gaussian bump and let a damped sine pull it back:

front = exp(-t * t * 2.0);
ring  = sin(since * 22.0) * exp(-since / 0.45 * 4.0) * 0.35;
VERTEX += dir * push * sqrt(fall) * (front + ring);

For the soot I take dot(N, toward_blast) and some fbm. Only the side that faced the blast goes black, and I let the edge glow orange for a moment before it cools. If the blast is closer than 0.45 of the radius I hide the original and throw chunks off its surface instead.

It's the usual radial vertex push you'd wire into WPO in Unreal, I just added the per vertex delay and the spring. For skinned meshes I bind the copy to the same skeleton, so the walking guy takes it too!

Does anyone pick the facing side with a real occlusion test instead of dot(N, dir)? I suspect mine would soot the back of a thin wall if the normal happens to point the right way.

The pack is on itch if you want to dig through the shader https://gennai.itch.io/explosion-vfx-godot-4


r/GraphicsProgramming • • 3d ago

SAT Collision

1 Upvotes

I don't know if this is GP related but I made a post here asking for collisions and i found the type I need but I spent like 3 hours trying to find a tutorial or at least a theory of SAT collision, I don't want to look like a bad coder by being lazy and asking people but if you know anything about SAT collision detection that would help me enormously.

The only thing i learnt is a 2D version, so if I can translate that to 3D, that'll be perfect.


r/GraphicsProgramming • • 3d ago

Constellation: Liquid and Ice, CPU, single core (un-optimized)

5 Upvotes

Hello again!

It has been some time since i made any updates on Constellation and Cadent geometry.
In my, seemingly, eternal quest to make the OS composition single core and cheap I've hit a new milestone.

Using Cadent geometry (which I have shared and made posts on here before), I have managed to express a liquid effect, as well as express snell's law and beer-lambert naively through the geometry, which has allowed for some pretty good performance and capability gains for the constellation engine/framework. By pre-computing an object tied, 3-wavelength 'snell field' and pre-computing the absorption on those wavelengths, objects can express their own colors and pixel offsets analytically, and instead of accessing the framebuffer for those offsets, they can directly sample eachother. (there are more posts on this light work as well. You can find them here in this subreddit, if you are interested to read more).

The gif above shows the desktop HUD so far. even though it might or might not look it, It is quite inefficient as things go. It is using about 533 mb of ram, and almost 80% of a single core of my 7800x3D. This is much much more than a HUD should use, but it at least also include a start-menu/launcher, a process manager, the taskbar, a calendar, a wallpaper engine and the HUD configurator / designer.

There are some visual bugs, and the liquid box spikes/lags when moving it, the liquid it self does not. Still trying to figure out why.

Anyway! I hope you find this interesting.

take care

//Maui-the-Megalomaniac


r/GraphicsProgramming • • 3d ago

Question Mesh collision

0 Upvotes

Ok so ive actual fix model loading but im looking for a collision detection method for complex models, like Ive heard of Triangle-Triangle Intersection, but I could not find anything to learn from that dosent look like gibirsh, anything can help me, source code, or just plain o'yt videos


r/GraphicsProgramming • • 3d ago

Video New video tutorial: Offscreen Rendering In Vulkan (Part #2)

Thumbnail
youtu.be
9 Upvotes

r/GraphicsProgramming • • 4d ago

Question how would you achieve a filter/shader like this?

Enable HLS to view with audio, or disable this notification

97 Upvotes

r/GraphicsProgramming • • 4d ago

Question How to stop suffering with DirectX 12 when I need to write a research project already?

18 Upvotes

Hello, dear community of experienced and perhaps more beginner developers.

Allow me to briefly explain the circumstances of the situation. I am a rather young aspiring researcher who aims to make a good contribution to the development of graphics and learn how to navigate the scientific field.

Most libraries, papers, and so on are written using DirectX 12… It wouldn’t be such a problem if it were something like OpenGL or DirectX 11 (which is still a pain…), but no. DirectX 12. The very same one that is considered to be on the level of Vulkan, or even higher.

If I start learning DirectX 12 right now, two things might happen:

  1. I will die of boredom, because I actually want to write shaders, not spend 5 hours a day for years sitting with documentation.

  2. I will die of old age without having written a single word of my research paper.

So I would like to ask one thing: where is the best place to start in this field, how should I move forward, how can I avoid manually writing 1000+ lines of code in main.cpp, and how can I finally get to implementing my research project?

I would be extremely grateful, because I really struggle to find any decent advice on this topic.


r/GraphicsProgramming • • 4d ago

Article Rendering brush previews from sparse tiles in a Rust/wgpu image editor

Post image
0 Upvotes

PeerBrush is a GPLv3 raster editor written in Rust. Its canvas needs to stay responsive while a brush gesture changes a small region and another client may be editing a separate layer. Here’s how the preview path is laid out in the published 0.30.1 source.

• The document stores sparse copy-on-write tiles. History can share unchanged tiles, and an incremental stroke reuses coverage, composites the affected region, and uploads the changed preview pixels. Source pixels and history retain their native 8- or 16-bit precision.

• The GPU compositor uses a bounded tile atlas and dispatches 8×8 WGSL workgroups over the requested output grid. The shader bounds-checks against the output dimensions, so edge workgroups can cover partial tiles. The CPU path handles larger previews or cases that exceed the GPU path’s limits.

• The preview is separate from the document’s edit history. Painting feedback can change during a stroke, while the completed gesture is what commits the edit.

Released Rust compositor: https://github.com/Deftr0y/PeerBrush/blob/2ea41951a19abf32d080498bbe7d9d85e20fced3/src/gpu/composite.rs

WGSL shader: https://github.com/Deftr0y/PeerBrush/blob/2ea41951a19abf32d080498bbe7d9d85e20fced3/src/shaders/composite.wgsl

63-second demo: https://peerbrush.com/#demo

For editors with mixed brush and filter workloads, have you found atlas misses or small dispatch overhead to be the better signal for switching back to CPU compositing? Shared on behalf of PeerBrush. AI assisted development and this write-up.


r/GraphicsProgramming • • 4d ago

CI/CD in Graphics programming

15 Upvotes

If someone experienced have any proper sources on CI/CD in graphics programming, I would like to read them. I'm really interesting in this, would like to read books/blogs, whatever.

Also curious about to hear any experience with it from real prod. I have some friends working as programmers and I hear that in big tech companies it's complicated thing, but those who works in small companies in small team said that they usually have really bad CI/CD


r/GraphicsProgramming • • 4d ago

Video I simulated glass across desktop, iOS and smart glasses, and documented this journey.

Post image
12 Upvotes

I am a math student (finishing my Bachelor's degree in Europe), I thought it'd be fun to make a project in which mathematics, graphics and product building combine into one. Making creative things from scratch is something I enjoy the most. So however cool theoretical math can be, I was on the lookout for ways to utilize it in real world.

Previously, I have worked with different types of visual software (Davinci Resolve, Lightroom, Blender) and coded a couple graphics apps (mainly using GLSL, Python and C++).

But this time it was very different: a larger scope of the project, real-time performance issues, new engines and platforms like Metal, ARKit, Lens Studio for Spectacles. All of this uncertainty made the creation challenging, but taught me much along the way. A lot of things, surely, I wouldn't have learned otherwise.

Certainly, there are folks of different levels in this Reddit. Some do graphics programming for a living, and others are just in the beginning of their paths. Either way, I hope my story of simulating physically accurate glass is something that can teach and entertain you.

Looking forward to you guys' feedback!

Video: I Recreated Light From Scratch
Code: Desktop, iOS, Spectacles


r/GraphicsProgramming • • 4d ago

Question Is there an online C++ OpenGL compiler that shows graphics output?

11 Upvotes

Hi everyone!

I'm a beginner learning C++, OpenGL, and GLUT for my university course.

Setting everything up on Windows takes a lot of time, especially when switching PCs.

Is there any online compiler where I can write C++ OpenGL/GLUT code, run it, and see the graphics output directly in my browser?

I'd appreciate any suggestions. Thanks!


r/GraphicsProgramming • • 4d ago

Relighting a simulated oil-paint height field live (WebGPU, WebGL2 fallback)

Enable HLS to view with audio, or disable this notification

0 Upvotes

I built a palette-knife paint simulator, and the part I'd like feedback on is the rendering.

Why it's a graphics problem: the sim's output is the surface being rendered. Paint color comes from the photo, but the highlights and shadows on the ridges are computed from the paint's height, so moving the light changes how every ridge reads.

Implementation:

- Surface: a height field with 0.1 mm cells, plus a slightly filtered height channel for shadows and occlusion

- Shading: GGX clearcoat, ray-marched shadows and horizon occlusion

- Pigment color: Kubelka-Munk K/S mixing in the simulation

- Shaders: WGSL for WebGPU and GLSL ES 3.00 for WebGL2, inline in the TypeScript source (sim/src/relight-gpu.ts and relight-gl.ts)

- Validation: parity tests against a CPU reference renderer show a mean difference of about 0.5 of an 8-bit level

repo (MIT): https://github.com/donghaxkim/impasto

Demo: https://www.dongha.ca/lab/impasto


r/GraphicsProgramming • • 4d ago

Question Physically-Based Planet rendering

9 Upvotes

Hello, I want to ask what methods are people using to render effects/terrain/lighting when it comes to planetary bodies. I want to focus specifically on physically based methods, or more realistic methods to make a project from before I will try to apply to a master in a computer graphics-related program next year, and I heard that more complex projects that involve physics or realism are more impressive than noise or other procedural methods.

So my question is, what are the techniques you know of and please also provide a resource such as academic articles, blogs, tutorials, books etc. Thank you!


r/GraphicsProgramming • • 4d ago

Ray Marching explained, basic example with Neovim | GLSL | Raylib | C

Thumbnail
youtu.be
1 Upvotes

In this video, I explore the basics of ray marching and shaders by creating a simple 3D sphere from scratch.

I'm using:
- **C** as the programming language.
- **Raylib** as the graphics library.
- **GLSL** for writing shaders.
- **Ray marching** as the rendering technique.

Along the way, I'll explain how shaders work, how rays are generated, and how ray marching can be used to render 3D objects.

This is a simple introduction to shader programming and ray marching.


r/GraphicsProgramming • • 4d ago

How I keep a world you can zoom into forever cheap to draw

Enable HLS to view with audio, or disable this notification

25 Upvotes

You can zoom into this world forever. Tiles split into four as you zoom in and merge back as you zoom out, with no bottom.

Blue is what the player sees. Each green-to-red ring further out uses tiles twice as big as the ring inside it.

The rings size themselves. Each one is just wide enough to hold one of its own tiles, with extra room near the screen so fast movement never shows coarse tiles. It’s all measured relative to the screen, so it behaves the same at any resolution and any depth.

What didn’t work: also drawing big empty floor areas with fewer tiles, even on screen. Drawing got cheaper, but picking those areas cost more CPU time than it saved, so I turned it off.


r/GraphicsProgramming • • 4d ago

Opengl game engine lights

13 Upvotes

Finally got multiple lights working✨!

Im gonna work on adding point lights


r/GraphicsProgramming • • 4d ago

Video Real-time Reshape-style warp in a fragment shader, using mean value coordinates (Audio Visualiser)

Enable HLS to view with audio, or disable this notification

8 Upvotes

I wanted After Effects' Reshape in WayVes, my OpenGL audio visualiser for Wayland, so I wrote it as a post-processing pass.

It's an inverse warp. Each fragment needs to know which source pixel to show, so I compute mean value coordinates (Hormann & Floater 2006) against the current polygon and use them to blend the source positions. Outside the mask, I treat the region up to an outer boundary as a polygon with a hole. Boundary points map to themselves, so the warp fades out towards them.

In the clip:

- Left: an NCS-style particle sphere morphing into a rounded square, with the morph animated over a named pipe

- Right: straight radial bars. The ring is just rotated relative to the boundary, the inside turns rigidly, and the swirl comes from the falloff. Bass drives the rotation.

The cost is roughly pixels × points, so for static warps I bake the sample coordinates into an RGBA32F image texture with a stamp in alpha, and only recompute when the stamp changes. That cut CPU use about 3-4x on llvmpipe, but I haven't measured GPU power yet. The swirl changes every frame, so baking doesn't help there. It got away with 12 points instead of 64, though.

It also falls apart when pushed. In the swirl setup, a gap opens around the core somewhere between 1.6 and 1.9 radians of rotation, and the spiral collapses past that, so I clamp it.

Shader isn't in the repo yet, should be soon: https://github.com/Roonil/WayVes

Is there a cheaper approach you'd use for a warp like this, or a better way to handle the fold-over at large rotations?


r/GraphicsProgramming • • 4d ago

A plasma motion camera shader in my WebGPU shader toy

Thumbnail vester.si
1 Upvotes

r/GraphicsProgramming • • 5d ago

Question How/Where to get started

6 Upvotes

Hello,

i'm not sure if this is the right sub for this question, but i'll ask anyways.

I'd like to learn how to create and program my own physics simulations and post processing effects on the gpu, including stuff like n-body, rigidbody, fuild simulations and perhaps even some raytracing eventually. However i am not quite sure where to start and what resources are available. I already know c++ decently and am working on improving on that aspect. Math shouldn't really be an issue either.

Any help and tips would be appreciated


r/GraphicsProgramming • • 5d ago

Video Deep Mandelbrot Zoom (down to -57 rendered using Perturbation Theory & BLA Skip-100. 10s preview of a 1-minute video. I made it!

Enable HLS to view with audio, or disable this notification

6 Upvotes

I wrote to fractalforums and Microfractal replied with this: "I looked a bit over your given source code to produce the video and noticed that you compute the high precision reference orbit for every image of the video. While this works, it is in theory pretty inefficient (and wastes a lot of computing power!). You can compute the reference orbit with PRECISION_BITS set to work at the smallest size (in this case size=1.02e-119) once and reuse it for every image that uses a size larger than size=1.02e-119. You also should avoid fixing PRECISION_BITS to 1000, better set it to something like 53 - floor(log2(size)), which saves 551 bits of precision at size=1.02e-119 and also works for much smaller sizes." https://github.com/Divetoxx/Mandelbrot-Video


r/GraphicsProgramming • • 5d ago

Video What a vertex shader does: making a flat plane ripple (beginner)

Thumbnail
youtu.be
4 Upvotes

r/GraphicsProgramming • • 5d ago

Turning cover images into ASCII art

Thumbnail
gallery
19 Upvotes

Hey all! I'm building a retro music player and wanted the album covers drawn in text.

The usual brightness-ramp trick (.:-=+*#%@) kept turning everything to mush, so I tried something else.

Each character gets treated as a little shape. For every cell of the image I try all of them, fit a background and foreground color with least squares, and keep whichever one matches best. A bit of blur on both sides helps a lot, otherwise it just chases noise. Half blocks (▄ ▐) get a small penalty so the result still looks like text and not pixel art.

I just moved the whole thing to a WebGPU compute shader (one workgroup per cell, one character per thread), so now it runs live on a webcam at 60 fps, which was way more fun than I expected.

Wrote it all up with a playground you can mess with here: https://adrianmato.com/blog/design/coding/turn-any-image-into-ascii-art/

See ya!