Archived

This topic is now archived and is closed to further replies.

LlamaGuy

Lighting trauma...

Recommended Posts

LlamaGuy    122
I'm making a water effect with a solid, untextured grid of quads. It's an array of floats representing the height of the water, my water function works fine and it draws fine... I'm just having problems with the lighting. I have a light positioned above the top right corner of the grid of quads, and I want quads with some smooth light. It works good, except if a quad is turned too much from the light it is darkened way too much, it stands out. My water function produces fairly smooth heights, so the angles of the quads in the grid don't contrast too much... but when the light hits one that is too far, it makes the quad black which doesn't look nice next to 100 other light blue quads. Here's my light settings... In init: GLfloat global_ambient[4]={0.2f, 0.2f, 0.2f, 1.0f}; GLfloat lightPos[4]={80.0f, 80.0f, -100.0f, 1.0f}; GLfloat lightAmbient[4]= {0.2f, 0.2f, 0.2f, 1.0f}; GLfloat lightDiffuse[4]= {0.6f, 0.6f, 0.6f, 1.0f}; GLfloat lightSpecular[4]={0.8f, 0.8f, 0.8f, 1.0f}; GLfloat lmodel_ambient[]= {0.2f,0.2f,0.2f,1.0f}; glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1); glLightfv(GL_LIGHT7, GL_POSITION, lightPos); glLightfv(GL_LIGHT7, GL_AMBIENT, lightAmbient); glLightfv(GL_LIGHT7, GL_DIFFUSE, lightDiffuse); glLightfv(GL_LIGHT7, GL_SPECULAR, lightSpecular); In draw: GLfloat glfMaterialColor[]={0.2f, 0.2f, 0.8f, 1.0f}; GLfloat specular[]={0.2f, 0.2f, 0.8f, 1.0f}; glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,glfMaterialColor); glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,specular); glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 4); glColor3f(0.2f,0.2f,0.8f); Yes, I calculate normals while drawing. Anyone have some suggestions for the light I'm trying to set up? [edited by - LlamaGuy on January 23, 2004 10:25:13 PM]

Share this post


Link to post
Share on other sites
orbano    130
please send us a screenshot! btw when making water, you should use high ambient light values, with not too strong diffuse, but very high specular value. you also set lightposition according to camera movement?

"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin

Share this post


Link to post
Share on other sites
LlamaGuy    122
I came up with a really good idea that I''m using instead. I disabled lights and change the vertex color based on the height map. So when the water is higher the vertex is lighter, and when it''s lower it''s darker. I get twice the frame rate too, slow that''s a plus.

Share this post


Link to post
Share on other sites
Enokh    122
Does it look good?

Also, what about transparency? Technically the higher amount of light that is projected on the surface of a part of water the more transparent it is. There are other properties such as the purity of the water (IE if the water is nearby a waste factory or in the middle of the pacific). You could make it so that the higher the water the brighter AND more transparent it is, but then you''re really swaying away from how it is in real life.

Share this post


Link to post
Share on other sites