PDA

View Full Version : Phong Shading - Troubles



GLmando
05-06-2015, 10:06 AM
Hello!

I need some help with my phong shading. I use opentk, C# and C++ (for the shaders).

I have to implement a light in my scene. The position of the light has to be indicated with this red cube in the middle of my scene. The calculation has to be done with phong shading.

The image below shows how the result should look like:

1804

The image below shows how my current scene looks like:

1802

Here is my code:

1803

The main problems: the light position has a really strange behaviour, the light doesn't have any impact on the second half of the plane and no impact on the character and the shading doesn't really look like a phong shading.

I really don't now what I am doing wrong.

I hope anyone of you can help me. That would be really great.

uwi2k2
05-08-2015, 12:00 AM
hi,

for the plane the basic problem may be the result of the dot() product.
if your light is shining straight from left to rigrt at its position, than the left half of the plane would be < 1.
but just a quick guess.

cu
uwi2k2

GLmando
05-11-2015, 12:35 PM
Thank you. You are right! :D