Minecraft-like Voxel type lighting?

Alright, but what I’m asking is how would I CHECK for the block which is a light source, and how many blocks away the block is from that, then setting the light source depending on that.

You’ll need an event system to detect when a voxel is created or removed. When that event is triggered, if it’s a light source (which is something you’d define yourself, perhaps also with an attribute), you would then set that voxel’s light level to 15 and then search for nearby voxels and modify their light level accordingly. Either search through the array or use the less performant GetPartBoundsInRadius method that I mentioned earlier.

If using an array, you can find nearby blocks by using offset math by adding or subtracting from the starting voxel’s position, and doing that for all 3 axis up to a certain distance away. But if you want that sort of star pattern, you’ll want to exclude voxels that are beyond a certain distance away, using something like magnitude perhaps, otherwise it’ll just light up the area as a square/cube.

This is probably about as much as I can say without outright giving you code.

Alright thanks, I’ll try it!

faefea

I managed to make something out of it!
image

2 Likes

Could i ask how you did this?
Im interested in making something highly similar but cant figure it out

I barely even got it working. All I did was loop through a folder (chunk folder) to check for light sources. Then looped through all other blocks and changed their color depending on how far they were from the light source.

1 Like

It isn’t really a good solution & can lag a lot so I’m still trying to find something that works.

I was planning to change the color of the decal/part using hsv to “emulate” lighting whilst having the actual source product a light but im not sure yet

Yeah, so either you need to basically make a full on game with a chunk system or you’re stuck with the lag. Or you know, embrace 2016 Roblox lighting.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.