I actually done it incorrectly here.
The correct formula is R/(square root of 3)
If you use a 3d ver of the Pythagorean theorem you get D^2 = A^2+B^2+C^2
But in this case, A, B, C is S or one side of the cube in the grid so it can be simplified as:
D^2=3S^2 or D= (3S^2)^.5. or D=S(3^.5)
R being the radius you are checking
D is the longest length from corner to corner in a cube so D=R or R = S(3^.5).
Since we have the radius (R) but want S we just divide both sides by (3^.5) to get R/(3^.5)=S
After consulting a friend (chatGPT o1 (gosh my future in CS is over))…
The entire cleanup code needs to be rewritten with a KD-Tree. If you are wondering what it is. Look it up.
We can use fewer points, and get less visible points, but it sacrifices some accuracy (to an acceptable level).
How it works is that instead of distancing one stud from the wall, it distances points from one stud from the walls, it will distance them by 1/3 of their light radius or half the distance the ray traveled (depending on which is smaller)
Edit 10 (spot and surface)
Full support for spotlights and surface lights.
(blue for spotlight, red for surface lights)
It has a few things not exactly shown, like how if you place NumberValue named “BakeryRange” and set it to a positive number, it will override the light’s current range (it also allows for way more than 60 studs range)
Oh and I recommend just turning off Default Casting and just tweak around with R1
(Don’t know why I just didn’t make it automatically tweak R1 by default)
Almost forgot, if you are doing like high-precision bakes, I hope you have a crap ton of ram. I’ve seen it use 21 gigs of ram before (while pushing this plugin to its limits) you prob won’t get to this level tho with normal usage.
Yo! Thanks for the response, I appreciate you giving me the file as I really did not expect you to respond lol.
I downloaded it, imported it and tested it for a bit and I gotta say it’s pretty cool tho I think it could use some work to make it even better than how it is as of now
Here is a list of suggestions I have in mind:
The UI honestly could use some work
Make it so you can bake lights that you pick/choose instead of baking all lights (unless I’m an idiot and I probably missed that )
I would add descriptions explaining specific stuff such as “Random 1”, "Random 2 ", “Base”, “Brightness Multiplier” and etc.
that’s it pretty much but as of now I think it’s pretty awesome! Good stuff!!
It’s kinda a little developerie thing, so only I really understand all of it. At some point, I would make it more intuitive and have more features. (I did think of making the area baking thingie where you can select specific lights, but I need to make some special points so the lights that are in that area can account for other lights that are already baked (in summary, it will take a long time))
Oh and my Discord is alex_ispig#0 if you need a faster way to contact me.
E1:
Now that I’m thinking of it… No I will not be planning on implementing baking specific lights, not ever. I have put into account for the technical aspect of it.
To do this: you must keep into account of every place points, this could be thousands, millions, or even billions. Most computers tend to have limited RAM, keeping the entire set loaded will likely cause some heavy usage of RAM.
And if I didn’t do this, the baking quality will not be up to standard.
Another solution is to bake everything but only add the specific points… Just bake everything at that point.
As much as I’m a sucker for realistic lighting, this just isn’t practical for production-level games, nor is it the way to go. The number of light instances used to light up a room with a single light source when just two (Source and Bounce) could be used (while still looking realistic) is just obscene. The way I see it, developers would be better off putting their time, effort and money into learning how light actually propagates and instead using that knowledge to more efficiently use light instances.
Take this free model I found and touched up on the toolbox for example.
No Bounce - 25 Spotlights, 0 pointlights