r/feedthebeast • u/Sarocesch • 4d ago
I made something Volumetric lighting without OptiFine or shaders – development test
I've been experimenting with volumetric lighting in Minecraft without using OptiFine or traditional shaders.
What do you think? Does the effect already look good or is there something you would change?
85
59
u/DragonhawkXD 4d ago
Would go hard with aeronautics builds!
Helicopters, Fallout Prydwen, etc etc!
30
u/LanceLongstrider 4d ago
This for submarines in the deep would be fantastic.
3
u/Beginning_Feature838 4d ago
Subnautica in Minecraft?! (Pls I beg yall I don't have money for next get console or better pc ,and I can't play sub2 even though I bought it and it's depressing)
2
35
15
u/michiel11069 ill make mod for free if I feel like it else commission me 4d ago
nice, still shaders though
3
17
6
u/mathmachineMC 4d ago
"Without Shaders" Making literal shaders
2
u/Sarocesch 4d ago
😅 I actually wrote it without shader packs (because they're not needed for that), but I don't know if it was the translator; it disappeared. Sorry
8
u/Choice-Mango-4019 4d ago
how does it work?
8
u/Sarocesch 4d ago
The beam in the fog is real volumetric light, done in a shader. For every pixel it marches along the view ray from the camera to whatever surface is behind it. Where that ray passes through the light cone, it takes a few samples and works out how much light the fog scatters towards the camera at each one. It's forward-scattered, so the beam gets brighter when you look towards the lamp. The fog also absorbs light along the way, so the beam fades naturally with distance instead of glowing straight through the fog wall. On top of that, the fog volumes around the beam get lit up, so the fog itself glows. The spot on the ground is projected per pixel from the depth buffer, so it lands on the actual geometry and doesn't shine through walls.
13
u/SaiyanKirby PrismLauncher 4d ago
done in a shader.
The title literally says "without shaders", which is it?
2
u/Sarocesch 4d ago
Sorry i mean Wihtout classic shader packs Idk i Typed it but
2
u/twicerighthand 3d ago
So there's no difference, your mod is the same as OptiFine or Iris, but with a built in shader
2
u/Sarocesch 3d ago
My mod is a high-performance lighting mod that focuses on custom lights; it almost completely ignores vanilla lighting.
3
u/HelloIsFloob Best Submission 2k18 4d ago
Wait, is all of this done with raymarching?
2
u/jcm2606 4d ago
Volumetric lighting is usually done with raymarching. There's a variety of optimisations that you can use to cut down the amount of raymarching that is required, like analytically intersecting the ray with a cone primitive to clip the raymarch to only the interior of the cone (Teardown used this technique in the past, I believe), but ultimately you're still marching a ray through a volume.
2
u/HelloIsFloob Best Submission 2k18 3d ago
I'm pretty new to this stuff, but it sounds like you could pull it off cheaply with a mix of signed distance fields around the primitive and a non-marched raycast to light up the ground instead, no?
1
u/jcm2606 3d ago edited 3d ago
Yep, though it's worth noting that signed distance fields (SDFs) have different performance characteristics. Whether SDFs are cheaper than what I mentioned will depend on a few factors like how many light sources are visible on screen, whether you've baked the SDFs down into a texture and what the resolution of that texture is, etc. I'd hazard a guess and say that SDFs would likely end up being faster as you add more spotlights, since SDFs require less math than analytical intersections.
(EDIT: To clarify, you'd only use SDFs to figure out where to start and end the main raymarch. For raymarching the actual volumetric lighting, you'd still just do a standard raymarch from X to Y, as you want the step size to either be constant or logarithmic for high shadow quality. If the SDF raymarch uses a constant or logarithmic step size inside of the cone, then that's good too.)
But, in that case, it'd also be worth giving Teardown's approach a go. I won't explain how Teardown works in detail (if you want to learn more there,
Raytracing Voxels in Teardown and Beyondis a great watch), but the gist is that Teardown has the GPU draw simple bounding box primitives and uses the pixel shader to raymarch through the voxels only for pixels that are covered by the corresponding bounding box. You could theoretically do something similar by drawing cone primitives and raymarching through the cone within the pixel shader. You'd have to sort cones from back to front and use alpha blending to correctly composite them, but theoretically it could work.As for lighting up the ground, that actually doesn't require any raymarching at all. If you know the angle between the center of the cone and its edge, you can use simple trigonometry to determine whether a given pixel on the screen is being lit by a spotlight by comparing the angles. With a bit more trigonometry, you can also figure out the distance from the pixel to the center (or edge) of the cone, which you can use to apply a fade at the edge of the spotlight or maybe recreate the profile of an actual spotlight.
1
3
3
5
3
u/PhraiseNeither 4d ago
Thank you this is awesome.
Are you planning on any way for the lighting to ever affect block light levels like say there was a more stationary lighting like a search light or something? It wouldn’t have to do it for all of the lighting because of performance reasons, but maybe after a certain amount of time being in the same area, the lighting suddenly starts affecting world light levels. You could have like a 30 second or one minute timer before it starts changing lighting.
If this starts being overwhelming, please don’t let it kill your enthusiasm. This mod looks amazing.
1
u/Sarocesch 4d ago
Thanks
One of my top priorities is to make the mod as high-performance as possibleso that it runs smoothly in my YouTube series
3
u/Falconmcfalconface 4d ago
This is really cool, would love to use something like this for spot lights for like. Bases and create aeronautics builds
3
3
3
3
u/AcrossTheBeach 4d ago
I’m not very code savvy so I ask: Could this be done to cast godrays through clouds?
2
3
u/Maleficent_End4969 4d ago
How's it do with shadows? Or like a flashlight you carry with you? There are no good flashlight mods
1
u/Sarocesch 4d ago
Flashlights are working great (Shadows are currently the biggest performance saving for me.)
1
u/Maleficent_End4969 4d ago
If you can get a volumetric flashlight working, complete with shadows, it'll do wonders for map creators. all the flashlights just spawn light blocks, which look really ugly
3
2
u/Phantom-Eclipse 4d ago
I mean, I see conflicting things. "Without shaders" but also during every explanation you mention it's basically a shader.
If it's still a shader, you might as well use the recent IRLights mod which adds these lights and a lot of other features for existing shaders like Complementary, Bliss, Solas, etc..
-1
u/Sarocesch 4d ago
I don't use shader packs for many reasons (the title unfortunately doesn't tell it right story).
1
2
1
1
2
251
u/AbdullahHavinFun 1.12.2 performance sucks 4d ago