lragnarsson/Emerald-Engine

Lighting on grass does not look good

Closed this issue · 4 comments

Flipping normal vectors creates popping effects. The reason is that light sources that "hit the backside" of a grass straw contributes with 0 light right now.

  • Disabling this check from deferred.frag solves the problem but this also means that light sources on the wrong side of objects contribute with light.

This image shows the problem. The whole area inside the red circle should get bright, because thats how grass works.
skarmavbild 2016-12-04 kl 17 34 39

These images illustrate the popping problem:
Notice how a few grass straws are almost completely dark in the first picture, while most are brightly green.
skarmavbild 2016-12-04 kl 17 24 35
skarmavbild 2016-12-04 kl 17 24 45

I am not sure how we should tackle this in our deferred fragment shader, since it cannot know that grass should be rendered differently from any other surface. One solution would of course be to run another fragment shader with just the grass, and keep the grass geometry in the normal pipeline for SSAO, but it would be quite performance heavy.

Maybe we can add a translucency value to our g-buffer which indicates how much light shines through a material? I don't know how well it would work but let's say 70% of light can be kept for grass if something shines from behind and 0% for our other objects? Will reduce the popping. Might be enough if we also have more random directions for grass. Perhaps we could have different facing normals on a grass as well?

Cool idea :) we should try that

We could also just set the normal to some linear comb. of the current normal and the surface normal. The two botton vertices should probably be shaded like the terrain surface.

Looks a lot better now.