- Home /
How can i "simulate" ambient occlusion and precomputed GI on procedural mesh?
So i am creating a voxel terrain similar to minecraft. I create only the faces that are exposed to air and also the uvs for the textures and the normals with the commmand: mesh.RecalculateNormals().The problem is that the terrain is illuminated at the same amount whether its day, night or a specific area is not "seen" by the sun at all, like a cave. Here are some pictures to make things clear:
This is the terrain during the day: [1]: https://ibb.co/fdEhxc
This is the terrain during the night: [2]: https://ibb.co/bPL0iH
And this is inside a cave: [3]: https://ibb.co/dEkGOH
I know that i cant bake at runtime but shouldnt the default directional light simulate this darkening effect? What can i do? Do i have to write a custom shader or something? Thanks in advance!
Experiment with multiple light sources from different directions. A good basic setup would be one normal one from diagonally above, like the sun, and one opposite which is far less intense and only serves to slightly lighten surfaces that are not lit be the sun. Also see if switching shadows for the light sources on and off makes a difference, as well as the ambient lighting amount.
@Cherno Thanks for the response! but im afraid i dont quite get you and you didnt quite get me.I have tried everything you said before except from the multiple lights. You mean multiple lights at the same time in the scene? I just use the default directional light. Also what i want is the more i descent in the terrain the less illu$$anonymous$$ated the area is but this is what i get ins$$anonymous$$d: [1]: https://ibb.co/kET7iH Some faces are lit as if they where exposed to the sun, which is not the case. I whould like to get smth like this: [1]: https://ibb.co/by$$anonymous$$SiH
You could use a shader that supports vertex colors and simulate lighting with it.
When using directional lighting, keep in $$anonymous$$d that surfaces that it can't reach because shadows = true and the surface is in a cave will only be affected by ambient lighting which leads to a flat, uniform look. That's why you should experiment with a non-shadow light. The same goes for surfaces that a light can't reach because it faces away from the light. This will also be only illu$$anonymous$$ated by ambient lighting, hence the need for a weak dir light ai$$anonymous$$g in the opposite direction.
For the "darker the deeper you go" issue, I don't know of any solution for this except a custom shader that takes y height into account or used vertex colors.
Your answer
Follow this Question
Related Questions
Layer based Ambient Lighting 1 Answer
SkinnedMeshRenderer modifying vertex colours? 1 Answer
Is it possible to fake Global Illumination within textures? 1 Answer
Scene is not pitch black when I set the Ambient Light Color to Black. 1 Answer
Turn off ONLY ambient lighting for just one object? 1 Answer