Ask about Phong shading using GLSL

I’m a beginner in GLSL, and have some experience in OpenGL programming. I did texture mapping, light source shading in OpenGL, I’m satisfied with the texture mapping but not happy with the built-in Gouraud shading. So I want to implement Phong shading using GLSL.
My question is can I just attach a “fp” GLSL program to realize the Phong shading effect and leave my texture mapping code in the original OpenGL program unchanged? Thanks.


Yes you can only attach a fragment shader, but I do not think that you will be able to compute Phong shading with only a fragment shader. Do not forget that you need to compute the incoming and outgoing direction rays for each vertex, and that you can only do that in the vertex shader.

Hope it helps!


Thank you very much! Then do I need to rewrite all the texture mapping code in the “vp”/“fp” again? In other words, can I just use GLSL to replace the light source shading part and keep the other part unchanged.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.