lwjglgamedev/lwjglbook-leg

Problem with point ligths

andersonarc opened this issue · 14 comments

I have been doing a project along with your tutorial (and some things I am doing on my own - multiplayer, etc.), but now I am stuck on chapter 10 with point lights. I just don't know what to do, because I tried changing shaders, copying the code from sources - it doesn't help. Link to repo - https://github.com/AndersonARC-e/graphics, I am using Kotlin language, Java 12 and OpenGL 4.5.

I will have a look at it.

Thanks a lot.

Hi,

I'm not able to launch the server so I have not been able to execute the sample. If you could reduce the code to something more manageable it will help.

In any case, I'm doing some guesses: Have you checked that the position of the point light is inside the veiw frustum? From your code (in the Renderer class) I see that you multiply the position of the point light by the view matrix, but then it seems that you do nothing with that result.

Another hint, have you tried to use RenderDoc to debug the values that get passed to the shaders? There's a chapter on the book that shows how you can use it. Maybe it can help.

Please let me know if some of this helps or how can I launch the server to try to debug something.

Hi,
Sorry, looks like I forgot to attach server application to repository. But code should work without server, actually. Maybe the code in repository is older than code on my PC. I will try to use your advices, and, if something changes, I will tell you.
I have tried using RenderDoc and attached it to JDK 12, compiled JAR of my project and root folder of compiled JAR. Everything worked correctly, but when I do a snapshot, it just doesn't record anything.

I have committed offline mode for client. And I have checked your guess about view matrix, and maybe I didn't get it, but after multiplying the position of currPointLight I set currPointLight as pointLight uniform. Also I have debugged the code and looks like currPointLight position changes when I multiply it by the view matrix, so modified position is set as pointLight uniform.

Oh, and also I forgot to load the resources to GitHub. Already fixed.
But if source code isn't launching, I have deployed built code in RAR archive to
OneDrive https://1drv.ms/u/s!AjXqXQkHCMcOiBD6FTgjEuLkb-IH?e=10gOVD,
Google Drive https://drive.google.com/file/d/1z8aedMxD58X5YGCcYbE1bVEHOZ56uYx_/view?usp=sharing

Just quick question. Is it the problem already fixed?

Unfortunately, no. I just have skipped this chapter to Assimp loading (because OBJLoader is loading objects a bit wrong) and now I'm trying to make it load materials (textures and vertices are loaded correctly, but material file is just ignored). But the point lights still aren't working.

Sorry, but the rar does not seems to contain source file but compilled classes. Could you upload everything to github ? It would be easier.

Source files are in https://github.com/AndersonARC-e/graphics, RAR file contains compiled version of GitHub code (actually classes are a bit older than GitHub version) so you can launch it without any problems.

Ok, sorry for the delay, but i don't have too much spare point. I've been able to run the sample in my environment with some tweaks and setup render doc. The problem is with the normals of the models. The normals are not being passed correctly. As you can see from render doc, they have no value.

screen-shot

I've modifie dthe shares to use a constant value for the normals and you can see some light. I still have to figure out why this is happening, but I cannot commit to any specific date. If you want you can check this in paralell.

Thanks for finding the issue, I will check my code and write here any new information.

Can I close this issue ?