PDA

View Full Version : ask about Phong shading using GLSL



jwe
05-04-2005, 08:40 PM
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.

WyZ
05-05-2005, 08:10 AM
Hi,

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!

WyZ

jwe
05-05-2005, 09:08 AM
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.