r/GraphicsProgramming • • Oct 25 '26

Video LittleJS now supports 3D and 2D: a small, fast WebGL2 rendering system for the web

0 Upvotes

LittleJS is an open source, dependency-free JavaScript game engine. It started as 2D, and this update adds a 3D renderer that draws into the same WebGL2 canvas, so a 2D game and a 3D scene can share a frame. The whole engine with 3D, Box2D physics and audio is about 150 KB gzipped. The trailer is the engine’s new website, a scrolling page over a 3D scene, with every stop a playable demo.

Some of the rendering choices:

  • Forward rendering with a small light budget. The sun plus the 8 point or spot lights nearest the camera, chosen each frame. Lights can carry a soft additive glow, drawn in the transparent pass.

  • One shadow map, from the sun or from a single spotlight in its place, with blurred edges and a depth bias scaled by the light’s projection.

  • Reflections from an environment cube map, with Schlick Fresnel. Roughness comes from mip selection, driven by shininess, but also by how fast the reflected vector changes across a pixel, so small mirrors don’t sparkle. The lake in the trailer has an environment map of its own, rendered from the scene.

  • A normal hook in custom shaders. A shader snippet can define mainNormal to bend the normal per pixel before lighting, specular, Fresnel, reflection and fog. The lake’s waves are that hook, not baked normal maps.

  • Automatic instancing. Every opaque use of the same mesh goes out as one instanced draw. Draw state is versioned, so a batch checks a single number per draw while nothing changes, rather than comparing every material field.

  • Lens flares occluded by raycasts against the triangles of the scene’s meshes, rather than a depth readback.

  • 2D and 3D in one camera system. An orthographic camera can line up exactly with the 2D camera. In the trailer, a dolly zoom flattens the 3D view into that orthographic view, and a Breakout game playing over the train turns out to be 3D objects in the world.

Also in there: height map terrain with exact raycasts, voxel maps drawn in chunks, glTF with skinning, normal maps, fog by distance or view depth, and a bloom post-process.

I also built an open benchmark that runs the same sprite and lit-cube scenes through LittleJS, PixiJS, Three.js, PlayCanvas, Phaser and Babylon.js: https://github.com/KilledByAPixel/webgl-engine-bench

Source, MIT: https://github.com/KilledByAPixel/LittleJS
The site from the trailer: https://littlejsengine.com


r/GraphicsProgramming • • Dec 19 '23

Question Why is unreal romanticized ?

21 Upvotes

Physics and cs student here, no experience with game dev. I’m learning though and I keep saying amazing unreal demos that showcase photorealistic graphics and every gamer I come across worship’s unreal and I’m just wondering if unreal was so good why wouldn’t everybody use unreal? And why wouldn’t everyone copy unreals tech?

And surely game engine isn’t the determining factor of how realistic a game looks right? What does game engine really mean? So many questions.


r/GraphicsProgramming • • Aug 04 '25

Question Why Are Matrices Used in Trivial Contexts?

18 Upvotes

I've seen graphics code in the real world which simply scaled and offset a set of vertices. A very simple operation, but it used a 4x4 matrix to do so. Why? Even with hardware acceleration and SIMD, matrix multiplication is still O(n^3) generally and O(n) at the minimum. Why not instead iterate through the vertices and perform basic arithmetic? Multiply then add. That's O(n) time complexity and very easily optimized by compilers. Matrices have a lot of benefits otherwise, such as performing many operations by combining them ahead-of-time and being well-aligned on memory, but the straight-forward approach of simple arithmetic feels more elegant. Not to mention, not all transformations are linear and can't always be expressed with matrices.

It's especially frustrating to see when hobbyists write software renderers using real-time matrix multiplication when it's far from optimal. It sort of feels like they're not really thinking about the best approach and implementing what's been standardized for the last 30 years.


r/GraphicsProgramming • • Apr 12 '26

Announcing "Easl", the Enhanced Abstraction Shader Language

11 Upvotes

Easl is a shader language that compiles to wgsl, with the primary intention of being used as a shader language for the WebGPU ecosystem. I've been working on it on and off for a few years and using it in some personal projects, and I think it's finally ready to share!

https://github.com/Ella-Hoeppner/easl

I made easl because I love graphics programming, but I found the existing shader languages to be pretty disappointing to work with. They typically stay extremely low-level and don't offer much in the way of building complex abstractions. That's fine if you're just writing small, simple shaders, but when I want to build more complex things and write re-usable code, I find that I quickly start to miss the conveniences of higher-level languages, especially functional languages. So easl exists to bring more of those convenient abstractions to the GPU, including:

  • Expression-based syntax (specifically a lispy, clojure-like syntax)

  • Sum types

  • Match expressions

  • Function overloading

  • Generics

  • Higher-order functions (as long as the arguments are inlinable at compile-time)

  • Closures

All of these are taken for granted in higher-level languages, but most of them haven't been brought into the world of shader programming yet. But thankfully all of these can be implemented as zero-cost abstractions even in a heapless context, so there's no fundamental barrier to bringing them to the GPU!

Importantly, easl does not try to jump all the way to being a purely-functional language. Pure functional programming is nice and all, but for performance reasons it's crucial to be able to do low-level imperative stuff too, so in easl you still have access to mutable variables, for and while loops with break and continue statements, etc. Pretty much anything you'd expect to be able to do in a traditional shader language, you'll be able to just just as straightforwardly in easl.

Easl is still pretty early, and if you use it much you may run into some bugs. If you do, I'd appreciate it if you'd file a github issue, or otherwise let me know!

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

Easl also has a work-in-progress CPU interpreter. This could potentially be useful for a few different reasons, e.g. being able to run helper functions with print statements on the CPU to debug and test them, and running simple shader programs using pure easl code without needing a separate "host" language to manage the CPU-side logic and window management.

However, this part of the project is still very new and experimental, and unlike the core compiler codebase, the CPU runtime was written with a lot of help from an LLM. I did it this way in the spirit of rapid prototyping so that I could quickly test out some ideas for how it could work, and I plan to eventually rewrite most of that code by hand, or at least go over it all with a fine-toothed comb and think through all the design decisions more carefully. If you're not interested in LLM-assisted projects then that's totally understandable, and you can rest assured that the core easl-to-wgsl compiler was written almost entirely by hand - it's only this experimental part of the codebase that relies heavily on LLM-generated code.

Nevertheless, in the long run I hope to flesh out this side of the project and make the CPU runtime into a more reliable, production-ready part of the project. Having to use two separate languages when doing graphics programming, a "host language" and a "shader language", introduces a lot of unnecessary headaches. Having one language that can run on the CPU but also on the GPU, and allowing the CPU side to easily dispatch to the GPU, can radically simplify graphics programming, especially when the language supports things like higher-order functions.

For instance, in the current version of the CPU runtime, the main way that you dispatch rendering requests to the GPU is with a function called dispatch-render-shaders, which simply takes two functions as an input - one for the vertex shader, and one for the fragment shader. Unlike the raw WebGPU API, you don't have to create any objects to represent the shaders, or any pipelines to describe the inputs and outputs - you just call a simple higher-order function, and the shared CPU/GPU type system fills in all the other information for you. The language will also track reads and writes of any buffers shared between the CPU and GPU and automatically sync them for you, so you never have to manually move data between the two. This is many orders of magnitude simpler than what you have to do with any traditional graphics API, and it all works in a fully type-safe way thanks to everything being captured in a single language.


r/GraphicsProgramming • • Sep 26 '26

Real time path tracer with ReSTIR and DLSSRR

Thumbnail gallery
0 Upvotes

r/GraphicsProgramming • • Mar 12 '26

I made a spectrogram-based audio editor!

27 Upvotes

Hello guys! Today I want to share an app I've been making for several months: SpectroDraw (https://spectrodraw.com). It’s an audio editor that lets you draw directly on a spectrogram using tools like brushes, lines, rectangles, blur, eraser, amplification, and image overlays. Basically, it allows you to draw sound!
For anyone unfamiliar with spectrograms, they’re a way of visualizing sound where time is on the X-axis and frequency is on the Y-axis. Brighter areas indicate stronger frequencies while darker areas are quieter ones. Compared to a typical waveform view, spectrograms make it much easier to identify things like individual notes, harmonics, and noise artifacts.

As a producer, I've already found my app helpful in several ways while making music. Firstly, it helped with noise removal and audio fixing. When I record people talking, my microphone can pick up on other sounds or voices. Also, it might get muffled or contain annoying clicks. With SpectroDraw, it is very easy to identify and erase these artifacts. Also, SpectroDraw helps with vocal separation. While vocal remover AIs can separate vocals from music, they usually aren't able to split the vocals into individual voices or stems. With SpectroDraw, I could simply erase the vocals I didn’t want directly on the spectrogram. Also, SpectroDraw is just really fun to play around with. You can mess around with the brushes and see what strange sound effects you create!

The spectrogram uses both hue and brightness to represent sound. This is because of a key issue: To convert a sound to an image and back losslessly, you need to represent each frequency with a phase and magnitude. The "phase," or the signal's midline, controls the hue, while the "magnitude," or the wave's amplitude, controls the brightness. In the Pro version, I added a third dimension of pan to the spectrogram, represented with saturation. This gives the spectrogram extra dimensions of color, allowing for some extra creativity on the canvas!

I added many more features to the Pro version, including a synth brush that lets you draw up to 100 harmonics simultaneously, and other tools like a cloner, autotune, and stamp. It's hard to cover everything I added, so I made this video! https://youtu.be/0A_DLLjK8Og

I also added a feature that exports your spectrogram as a MIDI file, since the spectrogram is pretty much like a highly detailed piano roll. This could help with music transcription and identifying chords.

Everything in the app, including the Pro tools (via the early access deal), is completely free. I mainly made it out of curiosity and love for sound design.

I’d love to hear your thoughts! Does this app seem interesting? Do you think a paintable spectrogram could be useful to you? How does this app compare to other spectrogram apps, like Spectralayers?


r/GraphicsProgramming • • Apr 11 '24

Question Reading a normal map cost me 100 FPS?? why? O.o

5 Upvotes

Edit: problem solved!

The issue wasn't in the geometry phase at all (by geometry phase I mean building the g-buffer), which is actually fast. But after this phase is over, I applied SSAO that uses the g-buffer normal map, and apparently something is broken there in a way that smooth surfaces = work very fast, 'bumpy' surfaces = very slow. The fact that I applied nomal map merely made the g-buffer nomals more random which made the SSAO that comes later slower.

Hi all,

I have a deferred rendering pipeline with PBR that I'm trying to improve its speed. I came to an interesting discovery, that if I take this part that reads the normal map:

normalColor.rgb = 2.0 * texture2D(texture1, fragTextureCoord).rgb - 1.0;
if (invertNormalMapY) { normalColor.y *= -1; }
normalColor.rgb = normalize(TBN * normalColor.rgb);

And all I do is comment out this line:

normalColor.rgb = 2.0 * texture2D(texture1, fragTextureCoord).rgb - 1.0;

Or even just replace this part `texture2D(texture1, fragTextureCoord).rgb` with just `vec3(1.0)`, suddenly I get over +100 FPS boost. Which is crazy.

Merely accessing the normal map cost so much. I made sure the texture has mipmaps, and its really not that big and nothing special about it. Also I don't render that many objects.

Its important to note that if I remove reading this texture it gets optimized out, which means I also don't set the uniform and then the Shader only have 3 textures instead of 4. But this shouldn't cost 100 FPS either because 4 textures shouldn't be a lot, and I only set the texture uniforms once and draw multiple meshes as instances.

Any suggestions what I could test or why this could happen?

Thanks!

EDIT: by 100 FPS drop I mean ~140 --> ~250, ie its a meaningful drop.


r/GraphicsProgramming • • May 18 '26

Question Why is the texture mapping of my minecraft grass texture so.. blended, if the filtering is correctly set to nearest?

Post image
1 Upvotes

Things i have tried:

the mag and min parameters of the texture are correctly set to gl.NEAREST and gl.NEAREST_MIPMAP_NEAREST

the overall canvas has the .imageRendering css property set to "pixelated"

the uv coordinates, for the face displayed, i believe are correct


r/GraphicsProgramming • • Mar 22 '25

Graphic Design Aspirant: Beginner

1 Upvotes

Guys, I am new to reddit and kind of new to computer science. I am looking to change fields from Data Analytics to Computer Science. I have been accepted into University for a Computer Science course for Fall 2025. I wish to pursue Computer Science with the intention of learning Computer Graphics and Game Design. I am very accomplished in Programming, but the languages are Python, R and SQL (usual suspects in Analytics). I am self teaching C/C++ (Still a beginner in these). I am competent with Mathematics as well (to a 3rd year Undergraduate level at least).

In the opinions of people in the industry, particularly in the field of the subjects that I have mentioned above, I would like to know what I can do to prepare for prior to classes beginning.

I hope that this pose satisfies the rules of this community.


r/GraphicsProgramming • • Jul 04 '26

Question Which Rust libraries should I use for OpenGL engine (beginner)

0 Upvotes

Hello, I'm totally new in graphics programming, I would like to make a 3D graphics engine in Rust but I d'ont know which library I should use ;

- Glow

- Kiss3D

- Bevy

- GL crate

- Glium

I d'ont know which one choose, if you can give an advice !

Thanks


r/GraphicsProgramming • • May 05 '26

Looking for a better B-spline rasterization algorithm for a specific case

0 Upvotes

Hi,
As part of a learn-claude project, I've been working on an implementation of the Kopf–Lischinski algorithm. The output of the vectorization algorithm is a set of indexed 3-control-point quadratic B-splines with 4 colour assignments (one per side, per half of the spline segment). The control points are roughly spatially indexable (you can reference them by their pre-optimization coordinates or their index), but are not really assembled into full chains; each spline segment is its own thing.

Since the splines are sort of spatially addressable, the algorithm I came up with for rasterizing these is for each output pixel, find the nearest spline and extract the color information from the nearest point on that spline (it's a bit more fiddly than that but that's the gist), as well as the distance and orientation from the center to compute pixel coverage and do analytical antialiasing. There are also special antialiasing paths for handling junctions and multiple curves crossing a single pixel, but that's not super important. This algorithm has some pros in that it is highly parallelizable and the simple case AA is free, but the actual computation per pixel is fairly bulky (read in a bunch of control points, solve cubic polynomials per curve (currently using an exact solver since I cannot find a consistently good seed for Newton's method...)) and the AA edge cases require tons of registers so occupancy is terrible.

This approach produces decent outputs:

but is quite slow. I can get it to run in real time on Game Boy and some SNES inputs at full speed at higher scale factors, but it starts to bog down as the number of control points spikes or the output resolution gets too high.

I'm looking for other rasterization algorithms that might be more performant. I'm also highly constrained as to what I can actually do, as this is a retroarch filter which is limited to a chain of fragment shaders (my upstream is compute shaders and much more flexible, so I'm interested in non-fragment options as well, but my main target is getting the retroarch version to run faster.) I've looked into Loop-Blinn, but it doesn't really work with the limitations RetroArch imposes, and something like Slug requires a bunch of preprocessing/also doesn't work in the RetroArch model.

The actual code for the downstream (of my compute shader version) RetroArch shader is here: https://github.com/libretro/slang-shaders/tree/master/edge-smoothing/vectorscale
(apologies for the general code quality, one of the rules for this project is not to write a single line by hand... )

Not looking for GTFO with your AI-slop comments. I'm genuinely trying to figure out a better way to get from the sort of odd, non-closed path spline data I have to a rasterized image.


r/GraphicsProgramming • • Jul 28 '26

Question What to do on the GPU and what to do on the CPU?

0 Upvotes

So consider for example a VFX for a game for a powerful shot from a magical bow. There is a line with an "arrow head" at the end and two smaller lines in a helix around the primary, closing in the further they get, joining to the "arrow head" in the end. The whole thing rotates over time to give the impression of "drilling" and it fades over time starting from the source end and finishing in the tip.

Thinking about effects like this in general. I see two possible approaches, both of which have upsides and downsides. In essence, I would like to know how would you decide what to do on the CPU and what to do on the GPU?

Approach 1: GPU focus

  • Make a single quad

  • Use a vertex shader to make it face the camera

  • Use a complex fragment shader to draw the effect

Approach 2: CPU focus

  • Spawn a cylinder for the central line and cone for the arrow head

  • Create a spline on the CPU for the secondary lines

    • Optionally use either vertex or tesselation shader to position the secondary lines

  • Use simple vertex shaders for changing colors and the fade.


r/GraphicsProgramming • • Dec 03 '23

How do you do version control when multiple people work on a unity project? GitHub says my files are too large.

Thumbnail self.unity
0 Upvotes

r/GraphicsProgramming • • Feb 21 '22

There is a WGPU subreddit!

1 Upvotes

Greetings, I found this subreddit for wgpu ( r/wgpu). It only has 56 members, and I thought that posting it here would help it grow. I put out a request on r/redditrequest for it in hopes of being able to moderate it, so I hope that happens.


r/GraphicsProgramming • • Apr 21 '21

HLSL shader for Vertical and Horizontal Softening.

0 Upvotes

Can anyone suggest me the best vertical and horizontal softening technique?


r/GraphicsProgramming • • Apr 15 '21

Looking for a Metal expert

0 Upvotes

My company is in search of an individual / small agency that specializes in graphics programming, specifically expert in iOS / Metal programming. Our group is taking a pretty different approach to some AR projects on iOS, working with some great talent from the console world to create specialized shaders that you might see in a high end game, but would almost never come across on mobile. I'm happy to answer any questions here or in DM.


r/GraphicsProgramming • • Jul 20 '21

Video It's too hot here. We want to beat the heat with snow.

1 Upvotes

r/GraphicsProgramming • • Feb 24 '25

The Sponza model is too big. I see Z-fighting if not scale it down to 0.02.

1 Upvotes

Not only Sponza. Every model in my renderer becomes very big and I need to scale it down. In VXGI sample from Nvidia they don't touch the model matrix at all and I don't see any issues with Z-fighitng. I use DirectX 11. Would appreciate any suggestion how to overcome this.


r/GraphicsProgramming • • Sep 05 '24

I started learning OpenGL to make a clone of Minecraft in C++

Thumbnail
youtu.be
1 Upvotes

r/GraphicsProgramming • • Jan 16 '23

What graphics books/api/resources would you recommended to a beginner with some C++ esperienze and 0 computer graphics knowledge?

1 Upvotes

r/GraphicsProgramming • • Nov 07 '24

openGL and SDL2 together

1 Upvotes

I was watching a video of JDH ,it was about making a quake/doom like video game ,he didn't go very deep into details but I heard him saying that he used openGL and SDL2 together .I'm not very knowledgeable in graphics programming so i was a bit confused because for me they are basically the same thing the only difference is that SDL2 is more high level than openGL .Did he use SDL for audio and input and openGL for rendering graphics ?Or is there a way to combine both just for rendering ?


r/GraphicsProgramming • • Feb 16 '21

What is the Game Engine used by Temple Run for IOS? Is it custom built ?

0 Upvotes

r/GraphicsProgramming • • Feb 21 '21

Video Game Graphical Coding?

1 Upvotes

Howdy!

I dont even know if this is the proper subreddit for this question, and I don't even think my question is proper, so I'll try my best to lay it out as simple as possible...

From my own record of playing and seeing video games within the past 5 years or so, I've seen graphics programmers give the ability of a game, at the lowest settings, to appear as those it seems to the naked observer, that the settings are all the way notched up when in fact it isn't.

I'm wanting to know the actual science behind it. What have these programmers found at their disposal that wasn't previously?


r/GraphicsProgramming • • Jan 02 '25

Question Best way to learn DirectX?

1 Upvotes

Couldn’t find any straight forward tutorials about dx12 and the dx11 ones are outdated. I am looking for a tutorial that will teach me from making a window to making a cube to adding in 3d objects and so forth. any suggestions?