PDA

View Full Version : specular lighting + 1D textures



mithun_daa
06-02-2004, 06:10 AM
hello everyone

im tryin to add specular light to my terrain which is colored using a 1D texture depending upon the elevation. the problem that i have is, when i take a look at the scene from top, it looks like a flat land but only the colors are different across it. it is working perfectly, but i was just wondering if there is any way i could giv it a depth feel when i look from the top. i think adding specular light to the terrain might help, i may be wrong. if specular lighting helps, how do i assign the specular property to the material when i have a texture?
is there any other way i could give a good depth feel.

here's some sample code

glMaterialfv faceFront, mprSpecular, sngSpecularLight(0)
glMaterialfv faceFront, mprShininess, sngShininess(0)
glColorMaterial faceFront, cmmAmbientAndDiffuse
glEnable glcColorMaterial

'enable 1D texture
glEnable GL_TEXTURE_GEN_S
glEnable GL_TEXTURE_1D
glBindTexture glTexture1D, TEX_1DSCALE

blnIsOpenglList = glIsList(intJ + (intI) * 10000001).................
.......

thank u

vincoof
06-02-2004, 08:28 AM
And what about simply using diffuse lighting ?

mithun_daa
06-02-2004, 08:37 AM
i am using positional diffuse light too. it looks good, but i was wondering if specualar light is gonna make it look better. and i dont know if im adding the specular property to the terrain right, cause there doesnt seem to be a change.

vincoof
06-02-2004, 08:54 AM
Almost all lighting effects give a better feeling of depth ; so, with regard to that, specular can help. But if you're looking for realistic-looking terrain, you're not gonna rely on specular lighting which is typically not very good on grass/sand/rock. Though it will be nice on water/snow.

As for your specular configuration, I think you're not in the right way.
Specular color should not be zero (prefer something like white=(1,1,1)) and shininess should not be zero either (prefer something between 10-20).
As a side note I don't know which programming language you are using. For that I assume that sngSpecularLight(0) means black color and sngShininess(0) means null shininess.

mithun_daa
06-02-2004, 09:37 AM
thanx vincoof


As for your specular configuration, I think you're not in the right way.
Specular color should not be zero (prefer something like white=(1,1,1)) and shininess should not be zero either (prefer something between 10-20).
As a side note I don't know which programming language you are using. For that I assume that sngSpecularLight(0) means black color and sngShininess(0) means null shininess.i am using VB6 as the language. and what sngSpecularLight(0) and sngShininess(0) means is that its passin arrays :
sngSpecularLight(0) = 0.5
sngSpecularLight(1) = 0.5
sngSpecularLight(2) = 0.5
sngSpecularLight(3) = 1

sngShininess(0)=50

what im worried bout is if its gonna affect the 1D texture or not, cause it doesnt look like it is.

dorbie
06-02-2004, 09:50 AM
You should use the separate specular extension to give post texture specular highlights that are applied after your texture modulation. Also do you have diffuse lighting correct? You say you don't see any relief when you look from above, this may be because the light is at the eye, don't do that, apply the light position after the viewing matrix is on the modelview to give a world space 'sun' light source, or the problem may be that you have no diffuse lighting.

vincoof
06-02-2004, 09:54 AM
If diffuse affects your 1D texture, then you're in some configuration that will take into account specular too.

If you don't see the specular highlight, here are some common issues :
- the angles between the light source and the viewer simply don't match to show the highlight. Try moving the viewer and/or the light source.
- the shininess is too high for the object tesselation. Try setting up a lower shniness (something like 1 or 2) and tesselate your object if you can.
- the specular color of the material OR the light is black (or very dark). Check the values passed glMaterial and glLight (seems like glMaterial is OK).
- the texturing stage is not correctly setup, for instance glTexEnv has been calles with GL_REPLACE, but I doubt you have done that otherwise the diffuse part could not be seen.
- the light model local viewing is wrong. See the documentation of glLightModel for more information about that issue. It's probably the last thing I would try though. The problem typically happens if the projection matrix is loaded with orthographic instead of perspective, and you're using the local viewer lighting model.