Thanks for your response. I've attached a small image showing an example
of the problem. In the picture you can see a series of brown cylinders
embedded in a blue plane with a yellow stripe. All of the cylinders
share the same geometry and appearance, and each are scaled down using a
transform group to the wanted size. The geometry was obtained from a
VRML97 file using vrml97.jar.

The single directional light in this image is shining down perpendicular
to the plane from the same side as the view platform, so there is no
reason to be seeing any specular color from this angle. There is also a
single ambient light. In this case, I didn't change the shininess, but
it has no effect even if I set it to 1.

The colors for the brown cylinders are as follows:
specular color: (0.0010, 4.7058825E-4, 0.0)
diffuse color: (0.7, 0.32941177, 0.0)
ambient color: (0.4, 0.1882353, 0.0)

The diffuse color is working well, sinde we can see some shading on the
rounded surface of the cylinders. The ambient color is also correct for
those cylinders that are brown on the flat surfaces.

For some reason, some of the cylinders are reflecting a bright yellow
specular color from their flat surfaces, even though I've set the
specular color to nearly black. I know it's the specular color, because
if I don't set it (leaving at the default of white), these cylinders
will be white on that side.

Also, if I use OrbitBehavior to move the viewplatform around, the
cylinders will flip rapidly between brown and yellow on the flat sides
(both sides when the light is shining directly from the top), achieving
a sort of disco-colors effect. I had to position the viewplatform very
carefully to take this picture when some of them were brown and some
were yellow. Admittedly, only the very thin cylinders have this problem
- the longer cylinders are always shaded correctly.

What results are you expecting?

I'm expecting the specular color to only be shown when the angles
between the surfaces, the light and the viewplatform are such that we
should be seeing it. I'm expecting the specular color to be the color I
set it to, and not a saturated rgb color. And I'm expecting a series of
shapes that all share the same appearance component and are all set at
the same angle to be the same color and shade.

See Section E.2 of the Java 3D Specification for the
complete lighting equations.

Thanks. I looked them over, and they make sense. The only variable that
I'm not sure of is the normals to the surfaces, because I didn't
calculate them. I just loaded the VRML file, used a recursive method to
extract the first Shape3D found, and then used getGeometry to extract
its geometryArray. I also iterated through its vertices to get its
current size so that I could scale it down to the size I wanted. I then
created the appearance object and the series of shape3Ds using the same
geometry and appearance component for each one. So there's a chance that
the problem is that it's just guessing what the normals are for each
surface are and getting confused. But in that case, why does the shading
work at all?
I'm not sure how to explicitly calculate the normals. I think I have to
dump the geometry array coordinates and coordinate indices to a
geometryinfo object, generate normals, stripify and then dump back to a
geometry array object. I haven't tried this yet.

There are some OpenGL issues with respect to the specular color when
applied to textured surfaces.

Isn't a textured surface when you attach an image to it? So how could it
have a specular color at all? Or do I have that wrong?

  You might try the D3D version of Java 3D to see if
that works better for you.

Actually I'm using Linux, but it looks funny in windows too, both OpenGL
and D3D. Actually, I just checked it in Windows and it looks even
uglier, with no shading at all. Maybe it is a normals problem.

Also, the apparent shape, intensity, and color of specular hightlights
can be greatly affected by the gamma correction of your monitor.  Make
sure they're all displaying the same gamma if you're trying to compare
specular highlighting effects.


How could I tell whether that's it? All the other colors on my monitor,
including images, look normal.

Thanks for your help.

Monica

<<inline: specular_color_problem_small.jpg>>

Reply via email to