lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3
https://ahbejarano.gitbook.io/lwjglgamedev/
Apache License 2.0
560 stars 202 forks source link

Issue with Normal Mapping and Shadow Mapping #14

Closed JAD3N closed 7 years ago

JAD3N commented 8 years ago

Hi, I've been following your tutorial/book. I've come across an issue that I cannot solve since I don't know where to start. When I use normal mapping on textures with shadow mapping I seem to get a weird shadow under the object. The light direction is going down but when I rotate an object it gets extremely dark and then light with a box underneath.

http://prntscr.com/czcw5g

Any idea to a solution would be amazing, great series and I appreciate the work you have been doing on this.

Also feel free to look into the code I'm using (the shadows implementation isn't at all optimised it's just to get it working). https://github.com/J4D3N/Spartan-Engine

lwjglgamedev commented 8 years ago

To be honest, I'm not able to quickly figure out what's happening. I will need more time in other to help you. Currently I'm having almost no spare time to dedicate to this. I hope the situation will improve ina couple of weeks, so I will have a look at it.

In any case, I'm not very proud about the shadows chapter. The implementation can be improved a little bit. You need to fine tune may different parameters in or to have it workinng. Besides that, there asome effects that are not addressed at all (like peter paning effect).

Thus, the current plan is to maybe write somtehing about 2D rendering and later revisit the shadows chapter.

Sorry for not being of more help (by now).

mudlee commented 7 years ago

@lwjglgamedev I also have problems with shadows, don't know if it's related to this though. I have strange shadows, you can check here: https://youtu.be/sVcyaCJsTWQ

lwjglgamedev commented 7 years ago

The code for the shadows chapter is far from being generic. You need to manually tweak the parameters for the light view matrix and the ortgraphic projetcion so you're scene is contained in it. From your vidoe what you are seeing is that this is not engough to cover the whole view frustrum.

Unforntaunatly, I haven't got time to quickly create a more general sample. You can manually tweak it to see if that helps or try to implement the more general approach.