5.0

5.0 | 1 rating Rate this file 7 downloads (last 30 days) File Size: 2.8 KB File ID: #23882

surfo

by Andres

 

24 Apr 2009 (Updated 09 Jul 2009)

Code covered by the BSD License  

workaround for surface lighting with OpenGL

Download Now | Watch this File

File Information
Description

There's a bug in the OpenGL renderer that produces faulty face lighting in surface plots, see picture above and http://www.mathworks.com/matlabcentral/newsreader/view_thread/249184 .
This submission contains a function that computes face normal data for the 'VertexNormals' property of the surface that fixes the lighting (facenorm.m) as well as a workaround function that you can just use in place of surf (surfo.m).
 
Only use this if you get erroneous surface plots and you can't go without OpenGL and flat lighting.

MATLAB release MATLAB 7.7 (R2008b)
Zip File Content  
Other Files facenorm.m,
license.txt,
surfo.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
08 Jul 2009 Jan Simon

Efficient, clear source code, help and example included.
The problem existed even in Matlab 6.5. Thanks!

Please login to add a comment or rating.
Updates
27 Apr 2009

perform meshgrid within facenorm.m, if necessary

09 Jul 2009

v1.01 · code with improved speed as kindly suggested by Jan Simon · minor text changes

Tag Activity for this File
Tag Applied By Date/Time
plot Andres 24 Apr 2009 10:01:17
surf Andres 24 Apr 2009 10:01:17
surface Andres 24 Apr 2009 10:01:17
surface normals Andres 24 Apr 2009 10:01:17
opengl Andres 24 Apr 2009 10:01:17
light Andres 24 Apr 2009 10:01:17
lighting Andres 24 Apr 2009 10:01:17
workaround Andres 24 Apr 2009 10:01:17
image processing Andres 24 Apr 2009 10:01:17
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com