Object looks translucent (not intended)

Started by
5 comments, last by davidcoleman 15 years, 3 months ago
My objects render translucent but I want the standard phong rendering look Where is the problem? GL.Light(LightName.Light0, LightParameter.Ambient, 0F); GL.Light(LightName.Light0, LightParameter.Diffuse, 1F); GL.Lightv(LightName.Light0, LightParameter.Ambient, new float[] { 0.0f, 0.0f, 0.0f, 1.0f }); GL.Lightv(LightName.Light0, LightParameter.Diffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f }); GL.Lightv(LightName.Light0, LightParameter.Specular, new float[] { 1.0f, 1.0f, 1.0f, 1.0f }); GL.Materialv(MaterialFace.Front, MaterialParameter.Ambient,new float[] { 0.0f, 0.0f, 0.0f, 1.0f }); GL.Materialv(MaterialFace.Front, MaterialParameter.Diffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f }); GL.Materialv(MaterialFace.Front, MaterialParameter.Specular, new float[] { 0.0f, 0.0f, 0.0f, 1.0f }); GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 100F); GL.Materialv(MaterialFace.Front, MaterialParameter.Emission,new float[] { 0.0f, 0.0f, 0.0f, 1.0f }); GL.Enable(EnableCap.ColorMaterial); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.Light0);
Advertisement
Since you are calling GL.Materialv, you don't need to GL.Enable(EnableCap.ColorMaterial)
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
glDisable (GL_BLEND)
It was not GL_BLEND...

I have tried also
GL.Enable(EnableCap.Normalize);
GL.Enable(EnableCap.RescaleNormal);
with no change

http://img222.imageshack.us/my.php?image=translucentnh3.png

I do not have calculated normals... can it be it? When I make face normals, then it is almost compleetly dark
if you want lighting....then you need (correct) normals. per vertex.
so
glNormal() gLVertex()
glNormal() gLVertex()
glNormal() gLVertex()
etc

When normals arent correct this obviously shows, but NOT by translucency.

if GL_BLEND is disabled, translucency might creep trhough via texture.
glDisable (GL_BLEND);
if blend is enabled, is only causes 'good' translucency with the proper glBlendFunc set.
so are you sure you're seeing translucency ?

check if all is ok WITHOUT light.
then ONLY enable the light, and if this is causing problemns, it shouldnt be something transparent.

in the screen i see NO transparancy at all
(also, am a bit confused now by transparancy/translucency. what should be wrong with the pic in http://img222.imageshack.us/my.php?image=translucentnh3.png
??? exactly)
I haven't looked very closely at your post or the replies, but I just wanted to point out that sometimes you can get something that looks arguably "translucent" if depth testing is not enabled and/or setup correctly.

That's probably not your problem, but I thought its worth a mention.
It seems we come from different backgrounds... I meant translucent as 3D studio max translucent parameter... not transparent but the light bounces within object... like Sub-Surfsace-Scattering, wax...

Here is another image
(the small brown line leeds up there to the light source)

If I turn off the light object is compleetly white. I tried now enabling depthtesting before rendering triangles but the result is the same

This topic is closed to new replies.

Advertisement