> Date:         Mon, 17 Mar 2003 16:02:37 -0800
> From: Monica Sleumer <[EMAIL PROTECTED]>
>
> 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 nted 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.

Specular works like a mirror: the effect depends upon the angle of the
eye to the surface as well as the angle to the light source.  From your
image, it looks like the end caps of the cylinders are positioned
appropriately for a specular reflection, so I don't see any surprises
there.

I suspect the reason that some of your end caps don't display the
specular flash at the angle you chose is because their normals are not
quite the same as the others.  They're probably very close, because as
you indicate:

> [...] 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.

Overall your colors look quite saturated, as if you're clipping at the
high end of the color resolution.  I wonder if your normals are longer
than the standard unit vectors.  That would also explain why your
specular colors are overwhelming the other color components: the dot
product of the specular half-vector and the surface normal is raised to
the specular exponent, so normally the specular contribution is never
more than 1.0, but if the surface normals are longer than 1 unit, then
they will easily overflow your color precision.

> [...] 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?

You might not notice small diffuse shading errors resulting from bad
normals, but specular effects tend to magnify errors because of the
exponentiation.  See what happens if lower the specular exponent to 1.0
from the default of 64.0.  You do this by setting the "shininess" in the
Material node component.

> 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.

Yes.  You don't have to stripify, but you might as well.

> >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?

It's not unreasonable to expect a textured object to be shiny, and to
have the color of the specular highlights reflect the color of the
light.

> >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.

Your video driver should have a setting for gamma correction, which
adjusts the relative brightness of the dark areas with respect to the
light areas.  You should set all your monitors to the same gamma if want
to compare colors between them.  Standard "linear" gamma is 2.2 (with
respect to the dynamic range of the human visual system) but most
monitors tend to set at 1.0 because that seems to be what most GUI and
game developers design for.

-- Mark Hood

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to