Rotating quads causes lighting issue

Hello once again.

I create my own X shaped grass using the following code:

I’ve tried quite a few things over a few weeks here and there, but I just can’t get rid of the problem. For some reason one side of the grass appears very bright. It’s the same regardless of whether shadows are enabled or not, it’s just more prominent with them enabled:

I have a sneaky feeling that one of the grass quads is providing “cover” for the other quad, and so one of them is bright, and the other is dark, at least it’s the only explanation that seems to make sense. The grass isn’t moved once attached to the rootnode, so I don’t think its as a result of dirty vertices.

Is it not just the lighting angle? What happens if you move the sun around?

I dont know the answer to youe question, but that is a pretty cool looking game. Do you mind posting a video or something?

Probably its because the jME3 lighting shader only handles one-sided lighting, i.e. the front side of the triangle. The shader can be changed to flip the normal for the back side of triangles, thus fixing the issue.

…but really, grass like this is normally set to use the lighting values of the ground underneath it because it looks less strange that way.

It’s really hard to do grass properly without a custom shader… whether modifying lighting as momoko_fan suggests or rolling something more custom.

I spent most of this morning trying various methods as you guys pointed out - and thanks for the suggestions by the way. Moving the light source made no difference, but @Momoko_Fan was right, I modified the shader to flip the normals and it appeared to alleviate it somewhat, but not entirely. I changed the texture of the grass to reduce the difference in brightness, and although not perfect, it’s a lot less noticable.

@8Keep123 - Once i’m happy with it overall i will definitely do so. As it stands right now i’m not 100% on everything, so it may well look a lot different to what it does now in the future, but here’s some screenshots for the hell of it:





1 Like

@jayfella That looks really sweet. Good luck on your game!