Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


[GLSL] Simple lighting shader not working


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 RobeeZ   Members   -  Reputation: 206

Like
0Likes
Like

Posted 23 July 2013 - 04:27 AM

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?

Attached Thumbnails

  • wtf.png


Sponsor:

#2 shazen   Members   -  Reputation: 285

Like
0Likes
Like

Posted 23 July 2013 - 05:45 AM

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, 23 July 2013 - 05:46 AM.


#3 RobeeZ   Members   -  Reputation: 206

Like
0Likes
Like

Posted 23 July 2013 - 05:49 AM

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, 23 July 2013 - 05:51 AM.


#4 RobeeZ   Members   -  Reputation: 206

Like
0Likes
Like

Posted 23 July 2013 - 10:07 AM

Okay, so I reduced it to render just one plane. And I found an other tutorial: http://www.rastertek.com/gl40tut06.html

 

I use EXACTLY the same shaders, and I use exactly the same position, and normals. But I got a black triangle instead of a yellow one. Looks like intensity is always zero.

 

The class of what I'm rendering: http://pastebin.com/ez5K9vN3






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS