EDIT: Fixed the problem. At least for my own purposes. It required playing around even more with light & material ambient & diffuse components and slight edits to the texture itself, so I’ll leave the original post intact in case someone finds an easy way to play with shading colors or something.
I’m running OpenGL functions through Psychtoolbox (a MATLAB toolbox) to draw 3D balls in a scene. I have the following situation:
https://www.dropbox.com/s/r81iv0b87omi8xe/emptyANDtexture_brighterYellow_Ambient_white.png?dl=0 , where the objects I use are on the right (yellow object) and the left one is just for testing purposes.
I color the yellow balls by mapping a single-colored texture on them (for my purposes, I need to use textures).
As you can see, the yellow ball has an outline from shading. I’ve already made it smaller by setting Material Ambient reflectance to white, but it’s still there. The white, testing ball on the other hand doesn’t seem to have such outline.
I’ve tried playing around with ambient light intensity, material ambient light reflectance, diffuse & specular lightings. I also tried to play with the glTexEnv parameters but couldn’t get rid of the problem. I’m not quite sure what I should try next, and how to approach this problem.
Here’s my code (used to produce the screen cap above):
- Lighting & environment:
glEnable(GL.BLEND); glBlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); glEnable(GL.LIGHTING); glEnable(GL.LIGHT0); glLightfv(GL.LIGHT0, GL.POSITION, [ 0 0 -1 0 ]); glLightfv(GL.LIGHT0, GL.AMBIENT, [0.2 0.2 0.2 1.0]); glMaterialfv(GL.FRONT_AND_BACK, GL.AMBIENT, [1.0 1.0 1.0 1.0]);
- Drawing texture objects:
ball = gluNewQuadric; gluQuadricTexture(ball, GL.TRUE); glEnable(gltextarget); glBindTexture(gltextarget, tex_id); glTexEnvfv(GL.TEXTURE_ENV,GL.TEXTURE_ENV_MODE,GL.MODULATE); glTexParameteri(gltextarget, GL.TEXTURE_WRAP_S, GL.REPEAT); glTexParameteri(gltextarget, GL.TEXTURE_WRAP_T, GL.REPEAT); glTexParameteri(gltextarget, GL.TEXTURE_MIN_FILTER, GL.LINEAR); glTexParameteri(gltextarget, GL.TEXTURE_MAG_FILTER, GL.LINEAR); glPushMatrix; glTranslatef( 484 , 384, 0 ); gluSphere(ball, 60, 20,20); glPopMatrix;
(the syntax might be slightly different from the conventional one, as these are MATLAB functions)
I basically set up the environment first, and draw the balls later. Any suggestions on how to remove the outline? I would like to preserve the slight shading on the surface of the ball to make it appear 3D.
Thank you in advance.