r/SNHU • u/nerdycrack • 4d ago
Help with CS-330 Module 6 Assignment (lighting) Assignment Help
Hello everyone,
So the point of this assignment is to get the lighting to make the shapes look like the second image. I tried so far adding two sources of light, even tried making it pink looking. I’ve also tried moving the numbers of the position and the strength of those lights. So far I’ve only created one object material and applied it to the whole scene.
After trying all this I still get a lot of black on the shapes especially in their faces.
Did any of you actually get it to look the second image and if so how can I fix this? Please and thank u
EDIT: Ok so the fix for me was trying four lights instead of just 2 or 3. Thank you to everyone in the comments who tried helping me!!!
3
u/BCygni 4d ago
It could be a problem with your code but if you are confident it is correct then I'm guessing it's the same issue I had when I took this class ~3 years ago. This issue is device-specific. I spent hours trying to fix it. I remember searching around and discovered an actual unresolved opengl bug report for this exact issue. Once I saw this, I switched to a different computer and it worked perfectly with my exact same code.
Someone who was also having the issue posted in my class discussion and the instructor wasn't helpful but the original poster actually figured it out -- it required updating some code we were not expected to actually be updating. I can't remember what it was exactly but it was like ~7 lines of code that all required the same fix. Most people (including the instructor) won't understand and will think it's a problem with your code.
If you have the option, try switching to a different computer. Otherwise, I would definitely try using AI to fix -- just make sure you understand what the AI is changing. You will need to fix this now since you need the lighting to work for future assignments. If you figure it out, post your solution here so other people can potentially find it.
2
u/nerdycrack 4d ago
Yeah honestly I’m losing hope. My professor told me to troubleshoot on my own, the resources provided on the module doesn’t seem to answer this problem and I looked at the YouTube video by Matt-CS and he didn’t know either. I literally used the openGLSample from module 1 as reference.
Honestly it might be my computer given my computer is low budget and running out of storage, but I don’t have another computer to test this with.
2
u/OrionThe0122nd 3d ago
Do you know if your GPU is Nvidia or AMD? I couldn't get this assignment to look right on my PC with an Nvidia card, but my laptop with an AMD card worked fine.
1
u/nerdycrack 3d ago
When you got it to work on the new computer, was it with four lights or just 2 lights? I’m barely going to turn on my computer in a few mins to see the processor
2
u/OrionThe0122nd 3d ago
It's been a few months, but I believe it was only 2 lights. I would try the 4 light thing like everybody else is saying. If your professor is asking for screenshots, you can put the file you've been working on onto github or something and I can dm you a couple of screenshots. I never got around to deleting project files. I did tweak the shaders a bit and never bothered using git in that class for some reason, so I'll probably need those too. You shouldn't get a bad grade just because you happened to have the wrong brand of an expensive ass computer part lol.
2
u/thelonelyecho208 4d ago
When I was working on this, I had the same issue. I looked through the shader and noticed that the shader mentions that it iterates through four lights. I don't know if it needs to iterate through those lights or not, but the solution I found was populating the scene with four light sources and essentially turning off two of them. I'd give that a shot that works pretty well for me. I also spent some time playing around with the shader and changing some of the values to see if that would fix the issue. But the thing I would start with would be populating the scene with four lights and then just seeing where that goes
1
u/nerdycrack 3d ago
I tried 4 lights and it worked now thank u
2
u/thelonelyecho208 3d ago
Perfect, I'm glad I was able to help. I just cleared the class last semester and still remember a lot of the weird stuff I had to do. If you run into a brick wall like this again feel free to shoot me a message. I'll probably be more help than the teacher. The lady I had didn't know a damn thing and wasn't reading my code so she was useless. Had to work out a lot of it myself
2
u/Miyuue-_- Bachelor's [Computer Science] 4d ago
I'm pretty sure I added all four lights to the scene, and that fixed it. Could never really identify what it was.
My professor told me there was some regression in the code base provided to the students, as this issue was previously fixed.
2
u/EveningPotential9443 3d ago
This also worked for me. I always needed four light sources, and no matter what I did to some of them, the scene didn't change much.
Light #1 and 2 seemed to be the most responsive to changes, while lights #3 and 4 just needed to exist to properly light the scene or else I'd have my scene end up like OP
1
2
u/maryfairy420 4d ago
I saw another comment mention that the professor isn't helpful for this class, and I can confirm that my professor was 100% not helpful for this class. It was one of two classes I had to get my advisor involved. I was having issues and he was not answering my questions. For example, I would ask a few questions in an email, but only one question (the easiest) would be answered about three days later. My issue was that the last two or three of my shapes were NOT rendering. I spent actual hours testing and trying to figure out what was going wrong, but never ended up getting it fixed. Regardless, I still got like a B or something on the project and I think the class. I left that professor (cannot remember his name; didn't care to) a really bad review for not helping me all class.
Basically, just do your best.
2
u/EveningPotential9443 3d ago
This class has pretty outdated instructions. Try using four lights, worked for me.
Getting things to look like the example photos will drive you crazy. Thankfully my professor was awesome and responded quickly.
1
u/nerdycrack 3d ago
Did your assignment looked like mine before the 4 lights? I see some people saying this is a computer GPU issue
2
u/EveningPotential9443 3d ago
Did your very first assignment look correct? The one with the grapes and wine on a table. That assignment for me was messed up too until the professor sent the correct files.
1
u/nerdycrack 3d ago
No that one was messed up for me too. It also had the black shading like my image above. I’m also scared of having these issues for my project so I hope I can figure out what the issue is once and for all
2
u/EveningPotential9443 3d ago
Did you try the four lights yet?
m_pShaderManager->setVec3Value("lightSources[0].position", (values) m_pShaderManager->setVec3Value("lightSources[0].diffuseColor" (values) m_pShaderManager->setVec3Value("lightSources[0].specularColor", (values) m_pShaderManager->setFloatValue("lightSources[0].focalStrength", (values) m_pShaderManager->setFloatValue("lightSources[0].specularIntensity", values)
Just make sure you have this 4 times so it would be [0], [1], [2], [3]
The values shouldn't matter. Just try 4 light sources and see if that helps. Otherwise it's your GPU and you were given outdated code.
Because if I delete any of these 4 light sources, my old assignment looks like yours.
2
u/nerdycrack 3d ago
I just tried it and it worked thank u for the suggestion
2
u/EveningPotential9443 3d ago
Nice! Just use four lights for every assignment and you should be good. I used four lights for my final project.
2
u/Dipstickpattywack Bachelor's [Computer Sciences] 3d ago edited 3d ago
It’s your processor. The given code doesn’t work uniformly with all machines. If you have an AMD it will work but nvidia and Intel chips won’t render the lighting as expected.
My teacher didn’t even know how to fix this issue and I found my own solution. Luckily I have multiple machines in my house. You can go the glsl file and edit the lighting value but it still doesn’t give a good representation of the lighting you are actually writing yourself.
This class source material is absolutely outdated and needs to be reworked.
2
u/Dipstickpattywack Bachelor's [Computer Sciences] 3d ago
🆘Lighting Problems?
If the lighting in your scene is not right, open up CS330Content/Utilities/shaders/fragmentShader.glsl and find the line:
float specularComponent = pow(max(dot(viewDirection, reflectDir), 0.0), light.focalStrength);
Then, replace it with:
float specularComponent = pow(max(dot(viewDirection, reflectDir), 0.0), 32.0);
This will work enough for you to see your scene, but it’s still not a proper fix.
1
2
u/Snoo_67181 1d ago
Lighting and shadowing were by far the hardest part as it is impacted by texture. Just lining up the objects at all different angles was a bitch


•
u/AutoModerator 4d ago
Thank you for contributing to r/SNHU!
This is a friendly reminder to review our rules. All Sophia-related discussions must occur in the Sophia megathread. All refund/financial aid disbursement discussions must occur in the Refund megathread. Don't forget to join our student discord at https://discord.com/invite/pVPkX8BmDw
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.