Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Problem with lights in GLSL

This topic is 2848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there, i'm making some terrain editing tools and I want to add some multi-texturing tools, but I have a problem combining textures with lights.

For this I'm using GLSL, and if I simply apply textures to my terrain I won't get any lights, because I'm not calculating them in my shader code. Right now I'm just using one texture and if I use the openGL lights I get something like this:


I like the effect and makes perfect sense in the program because I want a fixed light at those coordinates, so the farthest the terrain is the less light it "receives", but I'm not being able to do this using GLSL. For examples and tutorials I based myself on the code from this site:


But all the lights i use give me weird results, instead of having a gradient in my map due to the distance of my terrain I get total variations in the terrain color, just by rotating or moving my camera.

Just like in this example using the code from http://www.lighthouse3d.com/tutorials/glsl-tutorial/directional-lights-i/

I get some weird effects just by moving the camera to the right.


Am I missing something in my shaders code? If the lights work well using openGL lights I think the problem can only be from my shaders code and not from the openGL app...

Share this post

Link to post
Share on other sites

Am I missing something in my shaders code?

Judging by your description alone, then yes it looks like the problem is in your shader. That said, I can't say anything beyond that without seeing your implementation. I know you said you based your code off of that tutorial but seeing your code would help.

Another thing is you linked to a tutorial on directional lights though it looks like you're actually after a positional light effect or a spot light effect.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!