The question is answered, right answer was accepted
[Solved] GI like lighting in procedural world
So I have this procedural world that is generated at runtime and I'm not pleased with how the lighting handles the resulting mesh..
[Solved] 1. First issue is that I would like to have Global Illumination in the world but since it's a procedural world the possibility for that is out the window. So I'm stuck with pitch dark shadows in places where no light shines, is there any solution to this?? (Note that raising the ambient light just makes the now black area a bit brighter, leaving out the details of the mesh)
EDIT: I fixed this by changing my shader a bit.
[Solved] 2. Second issue is the directional light used as a sun doesn't know where not to shine it's light, it doesn't get blocked by terrain above a cave but instead lights up the floor inside the cave. Why does it do this and is there any fix for it?? (Note2 I'm using my own shader for the terrain in forward rendering mode but I doubt that is the problem) I have tested with disabling backface culling in the shader but that doesn't help at all..
A directional light has a shadow strength property you can use to make shadows not pitch black.
That does sadly not help here since those black areas aren't lit by any lightsource at all so there are no shadows either that can be causing it.
Oh, I see. You could add another light going in the opposite direction to brighten up these areas, but that probably wouldn't be much better than ambient lighting...
Are you using real-time shadows?
Copy your "sun" light source, give it an intensity of about 0.1 or 0.2, and don't let it cast shadows. This is your "back-up" sun which basically works as a form of ambient lighting that can slightly enlighten all the places that would be cast in shadow otherwise. The main advantage is that it will also pick up normal maps. You can go one step further and make another back up sun light, but let it shine in the inverse direction (diagonally upwards). With this setup, you will have all surfaces covered.
Like @multinfs said, black spots are not in shadow but just backfacing tris.
As noted on earlier comment, I have tested this and this is how it looks like: The bright area in the ceiling is the inverse light (intensity is exaggregated here to better show dark areas) and while most of the darkness is brighter it still leaves some faces that aren't lit at all. To make those lit too I'd need tons of directional lights in all directions which I'm not liking since I will Implement a day-night cycle later.
As I'm writing this I remembered that I can change the terrain shader code to potentially fix the dark areas.
You should be able to change the light-angle-falloff in a custom lighting function like the diffuse wrap example in the manual http://docs.unity3d.com/$$anonymous$$anual/SL-SurfaceShaderLightingExamples.html to get more details out of the dark areas. And for the sunlight inside the cave, enabling shadows is the way to go (what you described is the normal behaviour of virtual lights).
@multinfs Wow, how did you do the vertex welding for the terrain? Looks amazing.
If you have a solution, add an answer. If not, add a comment please. I've converted your answer to a proper comment.
Thank you! I've only seen a few billion answers that were actually comments today. I can't wait to get a few hundred more karma ;)
Don't "tag" questions with "Solved" or similar. Close them if they are answered so it it obvious. IF they are not closed, and someone comments, or edits some content on it, it will pop up on the feed of the front page, which is useless.
Answer by multinfs · Mar 02, 2016 at 11:45 AM
Soo, to make the solution clear to my problems I simply had to modify my shader a bit to 1. Handle ambient lighting correctly ( The ambient wasn't adding the color of the fragment but the ambient color only.) 2. Support shadows ( Added built in AutoLight.cginc functions to shader for shadows )
Follow this Question
Related Questions
How to get objects to spawn in according to rules 1 Answer
I want to create a billowing fog/cloud/dry-ice effect, possibly constrained 0 Answers
How do I hide an emissive object but keep its affect on the global illumination? 3 Answers
Shader help: Is it possible to make the sprite's under a circle/mask appear brighter/more vibrant? 0 Answers
Writing a shader that emulates graphic novel coloring 0 Answers