Strange patch behaviour when hgtransform applied to object

3 views (last 30 days)
Hi,
I have a patch surface consisting of triangular facets. I have a scalar field for with data for each node in the patch. This is used to generate a fringe plot. This has been working well.
p = patch(surf, ...
'cdata', field_values, ...
'facecolor','interp', ...
'facelighting', 'phong', ...
'edgecolor', 'none',...
'specularstrength', 0.1);
axis equal;
set(gca, 'visible', 'off');
caxis(color_scale)
colorbar('location', 'eastoutside');
light
I require orthogonal views of this patch surface. I tried to use hgtransform to re-orient the patch as follows:
% hg=hgtransform;
% set(p,'parent', hg);
% M = makehgtform('yrotate',-pi/2);
% set(hg, 'matrix', M);
The patch surface orients correctly, however the face shading is now distorted, which I guess is due to the vertex normals not updating to the new orientation.
Have I missed something, or is this an inappropriate use of this command, and I would be better off using the camera toolbar.
Thanks for any comments.
Regards Andrew Sims UNSW, Australia.

Accepted Answer

Patrick Kalita
Patrick Kalita on 1 Aug 2011
I think this is probably a bug in how the ZBuffer renderer does its lighting computations. If you change the figure's renderer to OpenGL, it should look fine:
set(gcf, 'Renderer', 'OpenGL')
One caveat: the OpenGL renderer does not support Phong lighting. So you will notice that even though the patch's FaceLighting property is set to 'phong' it will fall back to Gouraud-style shading when you change renderers.
  1 Comment
Andrew
Andrew on 2 Aug 2011
Thank you Patrick. That is very helpful.
Regards
Andrew Sims

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by