Zylann / godot_heightmap_plugin

HeightMap terrain for Godot implemented in GDScript
Other
1.75k stars 159 forks source link

DirectionalLight not lighting correctly (incorrect Normals?) #199

Open petterthowsen opened 4 years ago

petterthowsen commented 4 years ago

Describe the bug When I create a terrain, add a simple grass texture and light it with a DirectionalLight (rotated such that it points straight down) it lights up the terrain less than it does at 45 degrees. It looks as though the terrain normals are all 45 degrees off.

To Reproduce Steps to reproduce the behavior:

  1. Create a new scene with a new terrain
  2. Add a simple texture to the terrain.
  3. Add a DirectionalLight and set its rotation to -90, 0, 0

Expected behavior The expected behavior would be the same as if you add a simple Plane mesh and see that lighting it straight down produces the strongest lighting effect.

Screenshots Light Rotation at -90,0,0: https://i.imgur.com/UVkj8Cg.png

Light Rotation at -45, 0, 0: https://i.imgur.com/CEt2oeL.png

Environment

petterthowsen commented 4 years ago

It seems that this occurs with the Classic4 shader but not the Classic4Lite. Maybe it's not a bug?

Zylann commented 4 years ago

It's not really a bug. The reason it happens is because by default, when you don't setup normal maps, the shader will end up reading white pixels in the empty slot, altering the shading orientation uniformly. Basically, if you want to use Classic4, you must setup normal+roughness textures as well. If you don't use them, switch to Classic4Lite.