Jump to content

  • Log In with Google      Sign In   
  • Create Account


Got a problem with Phong Shading


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 Trazy33   Members   -  Reputation: 104

Like
0Likes
Like

Posted 18 June 2014 - 07:17 AM

Hey guys,

 

Me and a colleage are using c++ and opengl (compatibility profile for learning purposes) at my university and we implemented phong shading for point lights. Now we should program a little game, so we decided to create a simple space invaders clone.

 

For a start, we simply put a few GL_TRIANLE pyramid objects with a texture on the screen and everything looks fine, but if we activate the phong shading, suddenly the textures all turn grey and we can't find out why? There is one point light in the middle of the screen and the phong shading was implemented for point lights.

 

Interesting fact: if we import a 3ds model in there, the shading works normal, it just won't work on the openGL created primitves?!

 

(Btw: we are using a custom (Visual Studio 2013 Ultimate) project framework with GLUT, GLee and more libraries already built in.)

 

Here are some pictures of what i mean:

 

game with phong
Album: Test
4 images
0 comments

 

We are still openGL beginners, so be gentle with us, thank you!

 

regards,



Sponsor:

#2 3DModelerMan   Members   -  Reputation: 974

Like
0Likes
Like

Posted 18 June 2014 - 07:22 AM

If it works with 3DS models then I'd check the normals on your generated pyramid objects. Do you have ambient lighting as well? Because it almost looks like you have no normals and then attempt to apply lighting, obliterating all the material colors to black, and then adding in some sort of ambient term. Can you post your shader code?



#3 Trazy33   Members   -  Reputation: 104

Like
0Likes
Like

Posted 18 June 2014 - 07:25 AM

We have ambient properties of the light, textures, materials set as well yes. You can find the vertex/fragment shader code in the gallery postet above.



#4 HappyCoder   Members   -  Reputation: 2510

Like
0Likes
Like

Posted 18 June 2014 - 01:37 PM

I can't see the problem from the code you posted. I recommend you try to debug the shader code by assigning intermediate values directly the the output color.

 

For example, try to assign vertexNormal directly to gl_FragColor to make sure that the normals aren't zero and that they look correct. If they look correct do the same with  lightDirection and eyeDirection to make sure their values look correct too. You can also return intermediate values from calcualteSimplePointLight, such as 'diffuse' to make sure that looks correct too.






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