r/GraphicsProgramming • • 19d ago

Community New Rules: 4, 5, 6

138 Upvotes

Hey r/GraphicsProgramming

Added some new rules. This are the result of our prior request for comment.

The first target goal for these rules is to return the community attention back to the "doing" of graphics programming and its "how", the sort of content that intrigues the academics, professionals, and hobbyists seeking for deeper understanding. This is a community for people who thinks these topics are pretty neat, and need a place to talk about them with other people; it's never been about sharing pretty images (that's a treat).

The second target goal is solving the problem of AI Posts vs Anti-AI Comments that are dominating the discussion, rather than the discussion of graphics taking place. Hopefully the new rules put at end to that activity. We'll see.

This is just the first attempt, subject to change. Please feel free to leave comments.

Posts prior to now are grandfathered in over the old ruleset (because filtering the backlog would be a nightmare).

------------------------------------------

4. Posts Must Present a Topic

A post should present a question, implementation, or development story.

Fundamentally, it must be about "how" something was made, not "what" it is or is made of.

  • 4.1 Posts must include their topic in the immediate post body or a comment. Linking to another post or GitHub is insufficient.
  • 4.2 Exception: Rendering Framework, Driver, or SDK Projects intended for graphics programmer use.
  • 4.3 No Showcasing Projects

    • 4.3.1 Exception: Semi-annual Community Showcases.are allowed.

5. AI Disclosure Requirement

Post must disclose AI tool use in authoring post contents and linked projects.

  • 5.1 There must be an explicit disclosure in the post body or separate comment.

6 No Low Effort Posts or Comments.

Low efforts posts and comments that do not drive learning and discussion will be removed.

  • 6.1 Exception: Questions are permitted because they drive discussion.
  • 6.2. "AI Slop" comments are disallowed; they shut down discussion.

------------------------------------------

Notes

"4.3 No Showcasing Projects" is the reason Rule 4 and Rule 6 exist.

It used to be that we would have lots of questions, discussion posts, and only occasional project showcases when something got completed enough to present a render. Now, we're getting tons of the showcases, and none of the discussion about how they work. Final comments on these showcases like "Feedback on the implementation is welcome." tends to shut down conversation; being too broad to respond to.

But that means we need to say "something" is the thing we should be talking about in a post, so the real problem is the need for "Rule 4. Posts Must Present a Topic".

Rule 5 and Rule 6 are a pair. Those using a ton of AI to assist or fully create their works are required to indicate by how much. If the posts say it's made "AI Assisted with Claude" or "AI generated by multiple models", now readers know. And since they know, there's certainly no reason to repeat it by calling it "AI Slop", especially given how much that shuts down any discussion in depth.

"4. Posts Must Present a Topic" could probably use some better wording. "I made a thing" is technically a topic, but the spirit of the law is "A Topic that viewers would pay money to attend a conference to see." If you've ever seen SIGGRAPH, GDC, RustConf, or other professional conference talks, you know that it's often 1/10th "Check out this thing we made (and want to sell to you)" and 9/10ths, "Let's dig into this really fascinating problem domain and examine one solution within it." That's the "topic" rule 4 refers to.

(placeholder for more, as I'm sure there will be more)

--------------------------------------------

On Enforcement

I imagine this will require a LOT more moderation action, and I just got a new job that's running me a bit ragged. (Yay! / Ohno)

So I expect moderation speed will lag behind the requirement.'

Please, help us by reporting, and give us grace with your patience to respond in a little while. I do most of my review on the train home.


r/GraphicsProgramming • • 6h ago

Video Moiré Fractal with C, Raylib and GLSL

15 Upvotes

AI Disclaimer:

I did not use AI to code the fractal.
-----

I created a simple moiré fractal using C, raylib and GLSL shaders.

The idea is quite simple: start with two nearby centers and generate concentric circles around each one, gradually increasing their radius.

Then, using the radius as input to a sin function, I generate alternating light and dark values. By applying this to the colors, the two circle patterns interact and produce the characteristic moiré effect.

Complete coding session:

https://youtu.be/7MmUcDiOJDc

Source code:

https://github.com/FractalCodeRicardo/hangover-programming/tree/main/moire-shaders

Shader:

#version 330

out vec4 color;

uniform float time;

void main() {
  vec2 uv = gl_FragCoord.xy / 800;
  uv = uv - 0.5;
  
  float a = 30;

  vec2 center1 = vec2(0.1, 0.0);
  vec2 center2 = vec2(-0.1, 0.0);
  
  float d1 = distance(center1, uv);
  float d2 = distance(center2, uv);

  vec4 color1 = vec4(
      0.0 * sin(a * time*d1),
      0.8 * sin(a * time*d1),
      0.8 * sin(a * time*d1),
      1
  );

  vec4 color2 = vec4(
      1 * sin(a * time*d2),
      0.2 * sin(a * time*d2),
      1 * sin(a * time*d2),
      1
  );
  
  color = mix(color1, color2, 0.5);
}

r/GraphicsProgramming • • 9h ago

Fully Neurally Rendered object - ~2.7 ms average GPU frame time (256*256)

28 Upvotes

Fully neurally rendered asset (RGB, Normals, and Depth) rendered at an average of ~2.7 ms frame time on 8 GB RTX 5070 Laptop GPU by a custom model architecture in custom inference engine made with Rust, TensorRT, and CUDA kernels. Check out the README in this repo for details. I spent months working on it, the main bottleneck being compute for training, which I solved by making a custom data flow pipeline (the details of which can also be found in the repo) that allowed me to train these models locally. Do you think such tech would be able to make it to mainstream game dev?

AI Disclosure: This project used AI to create the GUI, and the product is an AI system


r/GraphicsProgramming • • 1h ago

Video Ray marched planets!

2 Upvotes

Heyo! This is partly a showcase of the early stages of my project, but also a sanity check if I'm on the right track or not with this.

I've had this idea for quite a while of rendering whole planets using ray marching SDF's, both from afar and up close, and now I've got this little demo of it. Not to go too far into it, here's a little rundown

  • Planetary surfaces are rendered using sphere assisted ray marching. It marches as closely as it can, and once it's within a tolerance, it computes the normal. This needs a lot more work, especially the SDF. Should bake something better than stock godot noise textures (which are 8 bit, among other issues).
  • Atmosphere is rendered by stepping through the atmosphere at small steps, and accumulating rayleigh and mie scattering for the final albedo and alpha.
  • Both of them use box meshes as their bounds, and those then have fragment shaders (this is also something I'm unsure about, as I've heard compute shaders might give more control; not sure if I need that control but anyway). One for the surface and one for the atmosphere.
  • I want to add clouds later but haven't looked into how yet.

At this point, without having optimized at all, it's running at around 0.75-1ms per frame, which is...fine? But there are so many bells and whistles left to add that I'm afraid the performance cost is gonna balloon, but at the same time I know there's a lot of performance magic to be done, so I thought I'd consult the wizards.

As far as I've been able to tell, there aren't really any big commercial games that go for this approach, and I'm beginning to doubt myself a tiny bit here whether this was the right approach (even though I think it looks really nice already from afar, even with just stock godot noise textures).


r/GraphicsProgramming • • 1d ago

shader-validator v2.0 release

Thumbnail github.com
8 Upvotes

Hey everyone !

I am working for quite some times on shader-validator, a VSCode extension that give the user a few handful of tools for writing shaders (HLSL / GLSL / WGSL). Its now passing a major milestone with an improved support for WGSL aswell as a lot of new features:

  • Disassemble your shader in one click
  • Write and validate WESL shaders
  • Improved HLSL support with namespaces and in out qualifiers
  • A lot more in release note !

Feel free to give me feedback or help as you can !

If you are interested in the underlying, I have also written up a few things about it there.

Ai disclosure: This post was made without the use of AI. The project was mostly done without it, but a few pieces and bug where resolved using ai agent.


r/GraphicsProgramming • • 2d ago

Made a Monte Carlo ray tracer in MATLab

Post image
124 Upvotes

I sort of followed the wikipedia article on path tracing and ray tracing in one weekend. I made it for a project in a numerical analysis course on Monte Carlo integration and used the rendering equation as an application. Even at 100 samples per pixel it is quite noisy, but I am happy that I managed to get an image out of it. Matlab is not made for this...


r/GraphicsProgramming • • 3d ago

Tips on self studying graphics programming.

31 Upvotes

Hey yall! I just finished school and want to self studying computer graphics to move into that field. While I was in school I was working on a raytracer but didn’t get to finish it. I know Vulkan pretty well, but not the best.

I have a game framework I’m working on with openGL but id like to change it over to Vulkan to use slang and such. Ngl my math is pretty rusty as well.

I’d just like some tips on where to start!


r/GraphicsProgramming • • 3d ago

Article Graphics Programming weekly - Issue 464 - November 23rd, 2026 | Jendrik Illner

Thumbnail jendrikillner.com
15 Upvotes

r/GraphicsProgramming • • 3d ago

Source Code Metal PathTracer v4.0.0 public release

Thumbnail gallery
31 Upvotes

Back in May I shared v3.0.0 of my Metal Path Tracer here, and the discussion that followed was really helpful.

https://www.reddit.com/r/GraphicsProgramming/s/zBgFRrDqk4

I've now released v4.0.0.

If you missed the earlier posts, this is a physically based renderer for macOS and Apple Silicon, written in C++20, Objective-C++ and Metal. It has hardware and software ray tracing backends, megakernel and wavefront execution paths, a ReSTIR/RIS/ReGIR research lighting stack, and an Embree CPU backend that I use as a reference renderer.

v3.0.0 was about scale: getting Bistro-class scenes to load and render. v4.0.0 is about correctness. Most of the work went into making the renderer agree with itself and with an independent reference. That means megakernel against wavefront, hardware against software tracing, and Metal against Embree. Every fix in the changelog lists the scene or test it was measured on.

Highlights:

  • Transport correctness: I fixed delta specular connections and MIS, camera ray distances, environment sampling, and the Plastic and CarPaint BSDFs. I also fixed a MIS double count on paths that crossed alpha holes, which could make images up to 1.42x too bright.
  • Direct lighting: ris_spatial, ris_world and the ReGIR merges are now unbiased on a sun-plane test with a known exact answer (2.33004 against 2.33005).
  • Embree parity: Embree now follows Metal's material, alpha-cutout and light rules, and it also runs Tungsten source closures. Several Bitterli scenes match Metal within about 0.06%. Embree's load memory also dropped sharply with bit-identical images. For example, Emerald Square went from 64 GB to 20 GB.
  • Subsurface: I rebuilt the random-walk SSS. On a unit sphere test it lands within 0.06–0.31% of Arnold's randomwalk.
  • Volumes and spectral: Homogeneous volume transport is fixed on every executor, and Henyey-Greenstein now follows pbrt's convention. There is also new hero-wavelength spectral transport with three wavelengths per path.
  • Radiance cache: It now stores actual radiance, with a bias below 0.03% of mean luminance. To be honest, it does not reduce error at equal render time yet.
  • Loading and performance: Scene loading is much faster. For example, Barcelona Pavilion went from 93 s to 23 s. Megakernel pipelines are now built lazily, so a cold start on one Bitterli scene dropped from 283 s to 69 s. A specialized megakernel pipeline is 1.6x faster on Sun Temple. Only two scenes were timed for that last result.
  • Denoising: OIDN guides are now averaged over all samples and follow glass and water. This fixed stair-stepped edges and milky water.
  • New scenes in the v4 asset pack: Barcelona Pavilion, Emerald Square, Sun Temple, and a set of vintage cars.

The main question behind this release was a simple one: how do you know that a GPU path tracer is actually right? Having a second, independent CPU backend turned out to be the most useful tool for answering it. Many of the bugs above only showed up as small ratios between two renders of the same scene.
Thanks again to everyone who commented on the v3 post. The full changelog has every fix along with its measurement.

GitHub Link:
https://github.com/dariopagliaricci/Metal-PathTracer-arm64

AI disclosure: This post was drafted with the help of Claude, based on the project's changelog, and then reviewed and edited by me. All renders, measurements and validation results come from my own runs of the renderer.

During development I used AI coding assistants (Codex and Claude Code) for parts of the implementation, refactoring and debugging. I directed the work, reviewed the changes, and validated the results against Embree and hardware/software ray tracing parity tests


r/GraphicsProgramming • • 3d ago

Question not a graphics programmer, but i wanted to know why scratch starts making these crazy patterns when i let whirl and fisheye effects grow exponentially.

Thumbnail gallery
15 Upvotes

https://scratch.mit.edu/projects/1444420354/ < see for yourself, you gotta watch it for a few minutes. removing the changing colors would probably help see it better.

i let the whirl effect grow by 1% of what its at every 0.01 seconds, and when it reaches a certain number, i let the fisheye effect do so alongside it. then eventually, scattering crazy white pixels appear and spread across the sprite, and then stop scattering randomly and start forming a beautiful pattern that's almost like a really crazy rug pattern, and then a circle of no white pixels grows from the middle and erases any white pixels it touches until there's no more, and then white rings start growing from the middle, almost looking like those lines that represent the planets orbiting the sun? and then those rings disappear, and the scattering white pixels appear, and the cycle continues forever. why?????? is this some crazy math stuff, or are the graphics glitching out, or what?


r/GraphicsProgramming • • 3d ago

Video Placing an aurora by the latitude of the curtain each pixel looks at, not the camera's

29 Upvotes

This is the aurora in my game Steadfall (Bevy/WGSL, a planet the full size of Earth). My first version gated the display by the camera's latitude with a wide oval falloff, so a storm could draw a full display overhead at 41 degrees, far from where a real aurora reaches. Here's how it works now.

Placement. The curtains are a field around the camera, raymarched in the sky pass. For each sample the shader works out the latitude of the curtain it's looking at, at about 3 km of curtain per degree (the real 111 km per degree scaled down by the curtains' height), with north as -Z. Under the oval nothing changes. South of it, only the curtains toward the pole light up, and they're far and low, so you get the real effect of a distant display sitting on the horizon.

The oval. Its equatorward edge follows the real one: about 64 degrees on a quiet night, 54 at Kp 7, 50 at Kp 9. Each night rolls an activity level, and a storm (activity above 0.7) lands a few nights a year.

Color and brightness. A far curtain is dimmed by its long, low path through the air (under half at 30 km) and shifts red with distance, since what survives of a distant display is its red top. Brightness is 0.15 + 0.85 x activity, scaled so a storm overhead is a few times brighter than a quiet arc, not a flat green wash.

Rays. The striation used to vary along one world axis, so an east to west curtain smeared into a band. It's now read off both horizontal axes, spread around the channel's median for gaps between rays, and its phase walks the height axis by whole turns so nothing jumps once a cycle.

Gates before any marching, cheapest first: not airless, sky reachable (no aurora in caves), sun at least 9 degrees down (full strength by 13), cloud cover under 0.55 (gone by 0.85), and an oval within 16 degrees. If any fails, the march is skipped.

AI disclosure: No generative AI


r/GraphicsProgramming • • 2d ago

Article How I enhanced the ThreeJS lighting pipeline in "Slop New York"

0 Upvotes

https://ben3d.ca/blog/enhanced-slop-new-york-lighting. (AI Disclosure per sub-rules: I used claude code in part.)


r/GraphicsProgramming • • 4d ago

Question Why SPIR-V Cross rejects to return a value for Bool types here?

Thumbnail chromium.googlesource.com
3 Upvotes

Function Compiler::get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) at line 2188 throws if the struct_type == SPIRType::Boolean with a comment // Bools are purely logical, and cannot be used for externally visible types.. I don't understand this. Why not return 1? What is the idea behind this?


r/GraphicsProgramming • • 3d ago

Video My dissolve front is a distance field with the noise multiplied in, not added

0 Upvotes

I pulled this dissolve out of a bigger Godot 4 pack and made it free. I give every fragment an arrival time, the earliest over all the hit points

float k = max(1.0 + irregularity * noise(p) * 0.6, 0.2);

arrive = min(arrive, hit.w + distance(hit.xyz, p) * k / speed);

hit.w is when that hit landed. So up to 8 hits just merge, like a union of distance fields. I multiply the noise into the distance instead of adding it, and that turned out to be the nice part. Near the hit point it barely does anything and the front starts round. It gets more ragged the further it travels.

After the front passes I use a second fbm to pick when each pixel actually goes

float erode = progress - (0.40 + fbm(p * 4.0) * 0.42);

if (erode > 0.0) discard;

The glowing edge is just erode near zero, white within 0.014 and orange within 0.07. I kept cellular noise out of that mask on purpose, plain fbm looks more like charred wood to me.

Once the holes open you see the inside of the mesh. I turned culling off and paint back faces (!FRONT_FACING) as dark soot with the edge glow at 0.7. Not sure that holds up on really thin meshes, I've only tried it on a mannequin and props.

Free download, Godot 4.4+: https://gennai.itch.io/free-dissolve-shader-godot-4


r/GraphicsProgramming • • 3d ago

Video 1 QUADRILLION instances (231.198 QUINTILLION triangles) in web gpu! Atomize Unity Port

Thumbnail youtube.com
0 Upvotes

I've been working on my own virtual geometry system called Atomize in Unity and decided to see what would happen if I ported the rendering architecture over to WebGPU.

Turns out you can push things pretty far in a web browser, even on my overheating RTX 3080 Ti laptop.

The engine uses METIS for cluster partitioning, QEM for geometry simplification and a hierarchical DAG for dynamic LOD selection. It also features a hybrid rasterizer, where larger geometry is handled by the hardware rasterizer and micro triangles are handled by a custom compute-based software rasterizer.

One of the biggest challenges was getting instance processing to scale independently of the total scene complexity. I ended up using compressed spatial tiles, procedural GPU instance generation and hierarchical rejection to eliminate entire regions of geometry before they even reach the rasterizer.

There's also frustum culling, cluster culling, backface culling, hierarchical Z-buffer occlusion and subpixel cluster rejection.

The model shown in the video contains 231,198 source triangles, with a procedural instance space tested up to one quadrillion instances.

Obviously, these aren't individually allocated objects. The whole point is to avoid processing geometry that has no contribution to the final image.

The entire engine currently runs from a standalone HTML file which is 1.08 Mb in size, which I find quite amusing considering where the project started.

AI disclosure: AI was used to assist with porting my proprietary engine code from C# and HLSL to HTML and JavaScript.


r/GraphicsProgramming • • 5d ago

Question How different really are D3D12 and Vulkan?

28 Upvotes

I am mainly a D3D and HLSL programmer and I want to learn Vulkan for cross-platforming. But how different really are they? I know a bit of OpenGL, and it is VERY different from Direct3d 11, which I used a lot.

Direct3d 12 is harder than D3d11, so it took me a long while to understand things more in-depth. Will at the very least some of that knowledge of D3d12 come in handy while learning Vulkan?

I've heard there are D3D12 concepts that do not exist in Vulkan and vice-versa. The biggest difference I am aware of is that D3D is more C++-styled while Vulkan is more C-styled.


r/GraphicsProgramming • • 5d ago

Simulating 3D Foliage purely in GPU - Uverse Game Engine

39 Upvotes

This is heavily inspired by "The Legend of Zelda: Breath of the Wild", but with combination of inspiration with Wall-E. Altho, I might change the main character for something else for better fitting to the natural environment lol.

What I've been mainly working on is Foliage (Grass) Simulation of which I added in Uverse (my own Game Engine) directly, and then I used it for this project for game demo, of which I am developing and focusing now!

This is made with own custom game engine (no threejs no godot) which runs natively in WebGPU/WASM but also supports natively in Direct12, Metal and Vulkan too. And this Foliage simulation has been rendered by vertex shader, not a geometry/mesh - The foliage simulation is actually split into small cells, and one instanced draw per detail level builds every blade in the vertex shader. No blade is stored. The grass is highly interactive with the wind itself (just two layers of scrolling noise for the gusts and a small per-blade flutter), highly customizable with the different grass colors, dryness, batches and of course, it also supports collision system to interact the grass with object. This is something I always wanted implement it for the past 15 years (when I was very young game dev), but only now I implemented it for the first time and I feel proud of this work. ^^

Disclaimer: Most code + 3d assets has been generated by Uverse's AI "Orbit"

If you have questions, shoot either here in comment or in DM! :)

Check it out at https://uverse.dev for more information

This method has been implemented from
Procedural Grass in 'Ghost of Tsushima' in GDC 2021


r/GraphicsProgramming • • 5d ago

Source Code Reverse-engineering macOS Liquid Glass into an independent Linux EGL/GLSL offscreen renderer (SDF unions, mip blur, and retargetable springs)

Post image
6 Upvotes

I have been working on an open-source offscreen glass renderer for Linux (written in Rust and Python with OpenGL 4.5 / GLSL shaders) that recreates macOS-style refractive glass effects, and I wanted to rewrite this in plain English to get some thoughts from the community.

At a high level, the host app gives the renderer the background image (like your wallpaper or desktop) and a list of glass shapes. The renderer blurs and bends that background through the shapes and returns the finished image.

Here is roughly how it works under the hood:

  1. Shaping and melting the glass: Instead of building 3D meshes on the CPU, the shader uses simple math functions (distance fields) to describe rounded rectangles and pills. A nice bonus of doing it with math is that two nearby shapes can smoothly melt into one another when they get close, without having to rebuild any geometry.
  2. Blurring the background without killing performance: Running a big blur directly on a full-resolution screen every frame is too slow on integrated GPUs. Instead, we shrink the background down step by step into smaller, blurrier copies and sample from those. The tricky part is that if you shrink too aggressively or sample across levels carelessly, you can get faint blocky or wavy patterns (what I meant earlier by artifacts) when things move behind the glass. Finding the sweet spot between smooth blur and low frame times is still a balancing act.
  3. Bending the light and edge highlights: Near the curved border of a shape, the shader shifts where it looks up pixels from the background, which creates that lens-like bending effect. It also shifts red, green, and blue slightly differently for subtle color fringes, and adds a bright rim highlight.
  4. Only updating what changed: When something small changes behind the glass (like a ticking clock or a moving cursor), the Rust side tries to only re-render that small rectangle. Since the glass bends light from nearby pixels, we have to expand that update box slightly so the refracted edges do not look cut off.

Questions I would love to hear your take on:

  • When you do blurred backgrounds behind UI elements on integrated GPUs, what approach gives you the cleanest look without hurting frame times?
  • If you do partial screen updates behind a refractive or blurred effect, how do you handle the extra margin around the dirty rectangle?

Source code if anyone wants to poke around the shaders: https://github.com/SaMaili/liquid-glass-renderer

AI disclosure: AI assistance was used to help draft and format this post (and rewritten here to cut down on the jargon).


r/GraphicsProgramming • • 6d ago

Article Practical, efficient render graphs

Thumbnail ipotrick.github.io
93 Upvotes

r/GraphicsProgramming • • 5d ago

Question How old is everyone here?

0 Upvotes

What are you working on?


r/GraphicsProgramming • • 7d ago

Good better at graphics programming for games and engines.

7 Upvotes

This may come off as a dumb question looking for advice, but I’m quite curious on ways professionals would approach getting better at graphics programming for video games and game engines.

I’m currently working on making a 2D game engine in openGL but I feel like using openGL is pointless and Vulkan would make a better fit.

Thoughts?


r/GraphicsProgramming • • 7d ago

Question Need Help with my Vulkan Renderer

4 Upvotes

Hello Everyone! Hope you all are doing well.

I am making a vulkan renderer for my FYP and I'm following the official Khronos Vulkan Docs tutorial. I am now on the vulkan simple engine section however, I am confused as to how to follow that guide because I am not able to understand how to connect all the things together. I am able to understand the concepts of different components such as camera implementation. I just need a guidance as to how to follow the tutorial. Are there any other helpful resources to use or is there an efficient way to follow the tutorial?

I can just see the structure from the repository engine code but I feel like that's cheating, I want to be able to understand things myself so later I can implement things according to my requirements and not feel completely lost. This is the reason why I have limited AI use to only understanding concepts and not code generation. I want to able to understand how the engine architecture works and make the most out of the tutorial. Any help would be appreciated.

Thank you.


r/GraphicsProgramming • • 8d ago

Article Same shader, two color spaces

Post image
22 Upvotes

Top row is Godot's Forward+ renderer, bottom row is Compatibility. That's the one web exports run on. On the left I just do ALBEDO = base_color * k, with k from noise on the first quad and 1.0 / 0.75 / 0.5 / 0.25 bands on the second.

On Forward+ the multiply happens on linear values and gets encoded at the end. So k = 0.5 should show up as about 0.51/2.2 ≈ 0.73 of the brightness, and I measured 0.717. On Compatibility it behaves like the multiply happens on the sRGB values themselves. 0.5 stays 0.5 (I got 0.496)! My stone mottling came out about twice as strong in the web build and I couldn't figure out why.

The docs do say Compatibility blends shadowed lights in sRGB. I just hadn't connected that to math inside my own shader. The right column converts around the multiply, only on that renderer:

vec3 s2l(vec3 c){ return mix(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), step(0.04045, c)); }
vec3 l2s(vec3 c){ return mix(c * 12.92, 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, c)); }

vec3 base = base_color.rgb;
#if CURRENT_RENDERER == RENDERER_COMPATIBILITY
base = s2l(base);
#endif
vec3 c = base * k;
#if CURRENT_RENDERER == RENDERER_COMPATIBILITY
c = l2s(c);
#endif
ALBEDO = c;

Now the bands match within 1/255. Vertex colors do the same thing, 0.25 reads 136 on Forward+ and 63 on Compatibility.

Is branching on the renderer what everyone does, or is there a cleaner way?

I ran into this building the demo stages for my Godot effect packs, which all run in the browser: https://gennai.itch.io


r/GraphicsProgramming • • 8d ago

Video Vulkan Dynamic Lighting - Directional, Point, Spot Lights, Tonemapping & glTF Lights

Thumbnail reddit.com
5 Upvotes