Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: problem with surface lighting (OpenGL)
Date: Thu, 16 Apr 2009 12:14:01 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 43
Message-ID: <gs77e9$fbj$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1239884041 15731 172.30.248.38 (16 Apr 2009 12:14:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Apr 2009 12:14:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:533185


Dear all,
please compare the surface lighting of the following four plots:

% -----------------------------------
[Y,Z,X] = cylinder([1.2 1 1 0.8],72);   % "[Y,Z,X]"!
X(3:end,:) = X(3:end,:)+0.5;

figure(1)
surf(X,Y,Z,'EdgeAlpha',0.2,'FaceColor','c')
axis equal off
light('Position',[0 0 1],'Style','infinite');

idxShift = mod(1:73,4)>1;
X(3,idxShift) = X(3,idxShift)+0.2;

figure(2)
surf(X,Y,Z,'EdgeAlpha',0.2,'FaceColor','c')
axis equal off
light('Position',[0 0 1],'Style','infinite');

figure(3)
surf(X(1:3,:),Y(1:3,:),Z(1:3,:),'EdgeAlpha',0.2,'FaceColor','c')
axis equal off
light('Position',[0 0 1],'Style','infinite');

figure(4)
surf(X(1:3,:),Y(1:3,:),Z(1:3,:),'EdgeAlpha',0.2,'FaceColor','c')
hold on
surf(X(3:4,:),Y(3:4,:),Z(3:4,:),'EdgeAlpha',0.2,'FaceColor','c')
axis equal off
light('Position',[0 0 1],'Style','infinite');
% -----------------------------------


I am not happy with the surface of figure 2 - which represents the one I need, of course :-(
The inner faces are irreguarly lit and look zebra-like, unlike those in the other figures (in my real application the effect is even worse).
Figure 4 comes close to what I want and expect, except for the double edge lines, but anyhow breaking up the mesh is not an option.
The renderer 'zbuffer' always gives a good face lighting, btw, but I need to control the transparency of the surface and the edges.

So is there any good explanation for why fig. 2 looks so different from fig. 4?
And hopefully even a workaround?
Thanks for your thoughts
Andres