Sign in to follow this  
chibitotoro0_0

OpenGL diffuse and specular for phong in opengl flipped?

Recommended Posts

Hi, I have been programming openGL for a while now and I didn't realize/address this problem until now. Maybe it's on my side but there's something I don't quite understand. NOTE: The weird looking diamond represents the light source. Question 1: In OPENGL when I use these settings: gl.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_SPECULAR,diffuse,0); gl.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,specular,0); I get the following render which resembles to the color output I'm getting from a sample render in maya. My OpenGL Render using the settings above: My Maya Render using the same settings: However, where I reverse the settings to what they're supposed to be: gl.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_SPECULAR,specular,0); gl.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,diffuse,0); The following render occurs: Question 2: Currently I'm only using LIGHT0. But the 'specular' only shows under certain angles. By certain angles, I mean angles in which the camera is lined up to the light and the object then it'll show. When the light isn't between the camera and the object, the specular spot doesn't show anymore. Comparing one that shows: To one that doesn't:

Share this post


Link to post
Share on other sites
You should tell use what diffuse and specular variables are. Presumably array of 4 floats with RGBA values. Since your two objects have different diffuse color, do you change it between each object rendering? I guess the diffuse is red/green and the specular is set to yellow/purple? If it's the other way around, you mixed up the names, but if it's that you have a problem.

But first, the way the light refract on the green cylinder and on the purple specular screenshot is not right. I would check the models normals if they are pointing the right way cause it don't look like it.

Share this post


Link to post
Share on other sites
newmtl phong1SG
illum 4
Kd 0.50 0.01 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 1.00 0.98 0.00
Ns 18.00
newmtl phong2SG
illum 4
Kd 0.00 0.50 0.05
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.85 0.00 1.00
Ns 18.00


The Cube is using the PHONG1 and the Cylinder is using PHONG2.
I'm using the default normals generated by the polygons in maya.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this