1

I am working on my final project for my Computer Graphics course. It is all done in OpenGL. My project is to create a simulation of bubbles underwater. It is not supposed to be realistic, however, I have done all the requirements from my project proposal, so I am looking to do some more advanced stuff.

Right now, my bubbles are not realistic. They are translucent, with a translucent white circle around each. The lighting is calculated using GL_LIGHT_MODEL_TWO_SIDE, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), and GL_POLYGON_SMOOTH. This gives an obvious bubble look.

The one thing that I can not get, is specular highlights! They are there, but they are translucent white, not opaque white of real specular highlights on a shiny surface.

If I set my alpha to all 1, then there are nice white specular highlights, but then my object is not translucent any more.

I have played around with GL_SHININESS, with little success.

Here is my code for lighting and materials:

glEnable(GL_LINE_SMOOTH);
glEnable (GL_POLYGON_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glShadeModel(GL_SMOOTH);

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);

GLfloat mat_ambient[] = { 0.1, 0.1, 0.1, 0.15 };
GLfloat mat_diffuse[] = { 0.5, 0.95, 0.8, 0.2 };
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_emission[] = { 0.0, 0.0, 0.0, 0.3 };
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
glMateriali(GL_FRONT_AND_BACK,  GL_SHININESS, 32);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emission);

Can anyone suggest a way to get bright, white specular highlights on a translucent object?

  • A snapshot of what you want and what you get might help us helping you with an answer – Jean-Simon Brochu Nov 22 '13 at 19:48
  • You'll probably have to write your own lightning shader. There are a lot of shaders emulating the "standard" OpenGL behavior, you could tweak it a little so that specular affected colors gets more opaque. fragColor = matSpecular * lightSpecular; fragColor.a = length(fragColor.rgb); something like that – Jean-Simon Brochu Nov 22 '13 at 19:52

0 Answers0