Thanks, Miguel. That all makes good sense.
Then the problem must be in the calculation of the vertex normals. I'm
displaying those now. (If you look again, you should see white sticks coming out
- those are tne vertex normals, and I can see that there are points where these
are causing trouble. Not because of a bug, but just because the combination of
Gouraurd and marching cube is not optimal.
The shading itself is great. So the Gouraurd methods are excellent. What is
getting messed up is the specular reflection. When that is off, everything looks
extremely nice. But the reflection itself has a very broken look when it is on.
So I'm guessing that it is very sensitive to each vertex normal. (Because that's
what determines the extent of "reflection", right?
In the Marching Cube business we get some very thin-sliced triangles, as you
mentioned earlier. It appears to be at those locations -- intersections very
close to a vertex point -- are where the problems lie. What I can see are
radically different vertex normals at almost the same location -- probably those
points your debug code was finding.
One solution would be to average the vertex normals for nearby vertices. Maybe
not too much of a load, considering we know that any such points from their edge
fractions. A bit tricky, perhaps....
Bob
Miguel wrote:
I can't figure out what is wrong with the isosurface specular display.
Please look at
http://www.stolaf.edu/people/hansonr/jmol/test/proto/new.htm?scriptno=3
Why the specular problem there on the lower right? I think if we could
solve
this problem, isosurfaces would look a whole lot better.
All suggestions welcome.
It is a difficult problem that is somewhat hard to explain.
The question relates to how shading is calculated. There are three main
types:
- flat shading
- Gouraud shading
- Phong shading
Flat shading simply uses the triangle surface normal to apply the shading.
That is, the entire triangle has the same color. That makes the
tessellation very obvious. I may be mistaken, but I think that there may
be an option to the 'isosurface' command that allows you to render with
flat shading.
Gouraud and Phong shading involve calculating the normal at each vertex.
This is done by averaging the normals of all of the triangles that touch
the vertex. How they are averaged can be important. If I recall correctly,
Jml currently uses a simple average. Another algorithm that might be
better would weight the faces that meet at a vertex so that faces with a
lot of surface area have more impact on the vertex normal.
Now that you have the vertex normals, you need to figure out how you are
going to interpolate across the face of the triangle.
Gouraud shading essentially does a linear interpolation of the pixels
between the vertices. This is what most graphics cards do because it is
fast and relatively simple.
This is basically what the Jmol g3d package does. It takes the RGB values
at the 3 corners and linearly interpolates between those RGB values. This
allows relatively smooth transitions of color as well as lighting.
Phong shading actually interpolates the normals at each point of the
surface. This gives much better results because the specular hiliting is
calculated at each point using the normal at that point. Since the
specular lighting function is so non-linear you get better results.
The problem with Phong shading is that it is very expensive. Basically,
you need to do vector transformations for each pixel. I may be out of
date, but I suspect that Phong shading is only available on very high end
graphics hardware.
If results are unacceptably, it is generally less computationally
expensive to increase the number of sample points and stick with Gouraud
shading.
Miguel
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers
--
--
Robert M. Hanson, [EMAIL PROTECTED], 507-646-3107
Professor of Chemistry, St. Olaf College
1520 St. Olaf Ave., Northfield, MN 55057
mailto:[EMAIL PROTECTED]
http://www.stolaf.edu/people/hansonr
"Imagination is more important than knowledge." - Albert Einstein
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers