Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecular highlights of a translucent object - OpenGL
    text
    copied!<p>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.</p> <p>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.</p> <p>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.</p> <p>If I set my alpha to all 1, then there are nice white specular highlights, but then my object is not translucent any more.</p> <p>I have played around with GL_SHININESS, with little success.</p> <p>Here is my code for lighting and materials:</p> <pre><code>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); </code></pre> <p>Can anyone suggest a way to get bright, white specular highlights on a translucent object?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload