Closed sourcerose closed 1 year ago
Sorry source I couldn't help earlier I have 2 kids and it's Christmas vacation , they kicked me out of the PC lol. I f you lower the ambient light and ground light and you add one huge light it will create a shadow darker and darker ,I saw it with my own eyes , but didn't have time to experiment , but today I had an idea if the light Wich is technically the sun , follows the player , the the shadow effect will follow the player also , please test it if you can thanks
Ok, I'll test it
I know this sounds dumb, but Im trying to use SpotLight.range = x
to change the size of the light but it's not working. Any ideas??
Made a Question on the BBJS Fourm. https://forum.babylonjs.com/t/spotlight-range-is-not-working/16784 I think it might be a bug.
Hi, so I could be misunderstanding the question, but in general I think light will always go through blocks unless you set up Babylon's options for handling shadows. Doing "real" shadows (where each light does tests against actual mesh geometries) is AFAIK not feasible for something like a big dynamic voxel world, so things like minecraft have a separate lighting system where the game engine tracks light levels for each voxel, and basically applies a tint to terrain graphics based on that, separate from the rendering engine.
OTOH if you're finding that lights aren't affecting meshes, I think there's also a limit on how many lights in a BJS scene can affect a given mesh. I think it's 4 by default, so the 5th light added to a scene won't affect anything unless various settings are changed. But I'm not sure of the details.
Any Ideas on how I could handle shadows? I've tried using shadowBuilder
and that doesnt seem to work. The light does diffuse with a spotlight
however only on the x,z axis. Not on the Y axis.
Hi, sorry I thought I replied to this. Basically handling shadows at the "meshes and lights" level is a Babylon question, and I don't know very much about it. My suspicion is that it couldn't perform well, due to how many terrain meshes would need (or potentially need) to cast shadows on each other. But I haven't tried anything similar.
(All that is separate from the question of handling lighting at the "voxel engine meshing" level, which isn't currently planned for noa
.)
It definitely is a problem with Babylon. I don't know how well shadows would work with this performance-wise, but in other environments one can have shadows and 3D lighting while keeping a smooth performance.
It's been over a year. Recently I was making my own voxel stuff for fun when I remembered Noa engine. Apparently, shadows don't have much of a performance hit. I've since tested them on some pretty wild and large terrain. I scrappily implemented BabylonJS shadows into Noa. Here is a picture:
I'm using a frustum size constraint, not for performance, but just to keep the pixelation of the shadows down (currently using 2048px shadows, although performance didn't change much with 4096px). The main problem with shadows right now is that BabylonJS self-shadowing isn't the best.
Here's a GIF demonstrating it:
Wow, this looks really impressive. Was the code straightforward? I'd like to check out how it scales to larger draw distances!
Wow, this looks really impressive. Was the code straightforward? I'd like to check out how it scales to larger draw distances!
Sorry for the delayed response (this got lost in my email over Thanksgiving). Yes, it was straightforward. I believe I just created a sun light, added a ShadowGenerator to it, updated your code to add meshes to the generator, and changed something to move the sun light above the player.
Sorry for the delay here. Noa v0.33 now adds a bunch of internal changes meant to enable clients to use Babylon built shadow generators, which seem to work pretty well and performantly. The examples repo now have shadow generators in the test
and stress
worlds, which should give a general idea of how to go about it. Thanks for all the feedback here, especially @Codezilluh !
I'll close this now; if you find bugs or missing stuff please track them in a fresh issue.
For some reason, light is traveling through the blocks. Is there anyway to fix this without implemeneting a really complex lighting system? This also Happens with SpotLight, PointLights, Directional, Hemispheric etc.