Jump to content
  • Advertisement
Sign in to follow this  
robee00

[GLSL] Simple lighting shader not working

This topic is 1766 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

Hello!

 

For now, I used OGL in fixed function mode. But now I want to learn the programmable pipeline now.

 

I tried to implement a simple diffuse - specular lighting shader from http://www.lighthouse3d.com/tutorials/glsl-core-tutorial/directional-lights-per-pixel/ . But I got wierd results (picture attached)

 

I uploaded my code to pastebin:

 

- Rendering: http://pastebin.com/cUDtHcWJ

 

- Vertex shader: http://pastebin.com/hE8s3KE7

 

- Fragment shader: http://pastebin.com/pVpr6zhR

 

And if I move my camera further the object, it gets brighter. Something I had to do with the position right?

Share this post


Link to post
Share on other sites
Advertisement

What I notice is that you only have 16 vertices available in your vertex buffer. To make a cube you need 24.

 

Each corner has 3 faces meeting all with different normal directions. Since you need a unique normal for each triangle then you need 3 vertices per corner. 3 x 8 = 24.

Edited by shazen

Share this post


Link to post
Share on other sites

Oops, I forgot to add that I left out the top and bottom sides. But okay, I'll try to rewrite that, and include the top and bottom sides

Edited by RobeeZ

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!