bugGNU Octave - Bugs: bug #53958, 'light' function not working for...

 
 

bug #53958: 'light' function not working for patch objects

Submitter:  Richard <crobar>
Submitted:  Mon 21 May 2018 03:32:30 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 21 Aug 2018 08:10:55 PM UTC, comment #8: 

The part of bug #54024 that prevented this from working correctly is fixed.

The example from comment #1 should display correctly now.

Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Thu 12 Jul 2018 10:12:13 AM UTC, comment #7: 

This bug "'light' function not working for patch objects" depends on bug #54024. Adding that dependency.

Markus Mützel <mmuetzel>
Group administrator
Wed 13 Jun 2018 07:32:30 AM UTC, comment #6: 

The "VertexNormals" are calculated only if "VertexNormalsMode" is "auto", "FaceLighting" or "EdgeLighting" are set to "gouraud" and a light object is present in the same axes.
For the "FaceNormals" to be calculated, "FaceLighting" or  "EdgeLighting" has to be set to "flat" (which is the case with the default values) together with the other two conditions.
That is what Matlab seemed to do when I looked at it.

Maybe this should be documented somewhere. But I don't know where this would fit. In the docstrings for patch and surface maybe?


With the default values there are currently no visible lighting effects because of bug #54024.

Markus Mützel <mmuetzel>
Group administrator
Tue 12 Jun 2018 06:55:34 PM UTC, comment #5: 

I just tried tst_light.m and the "FaceNormals" property is now calculated, but the "VertexNormals" property is still an empty matrix.  Is that expected?

Rik <rik5>
Group administrator
Mon 04 Jun 2018 08:15:34 PM UTC, comment #4: 

This should be fixed with this changeset:
http://hg.savannah.gnu.org/hgweb/octave/rev/107920dd7715

The issue that facenormals are not taken into account for lighting is tracked in bug #54024.

Markus Mützel <mmuetzel>
Group administrator
Tue 29 May 2018 11:18:35 AM UTC, comment #3: 

This was also reported before in bug #51875.

Maybe we could leave this bug open until the actual feature (automatically calculating normals for patch objects) is implemented.

Markus Mützel <mmuetzel>
Group administrator
Thu 24 May 2018 08:02:35 AM UTC, comment #2: 

Fwiw, there is a (quite old) patch in patch #8951 that added support for automatically calculating vertexnormals for patch object. I don't remember how complete it was and I don't know whether it still applies on a current tip.

Adding as a dependency anyway.

Markus Mützel <mmuetzel>
Group administrator
Wed 23 May 2018 09:14:12 PM UTC, comment #1: 

I've simplified things further.  There is now just a single data file, patch.mat, and a single test file, tst_light.m.  Both are attached to this bug report.

Have you looked at the help text for light?  It seems that you need to supply the vertex normals when you are working with patch objects, as opposed to surface objects.


     Create a light object in the current axes or for axes HAX.

     When a light object is present in an axes object, and the
     properties "EdgeLighting" or "FaceLighting" of a 'patch' or
     'surface' object are set to a value other than "none", these
     objects are drawn with light and shadow effects.  Supported values
     for Lighting properties are "none" (no lighting effects), "flat"
     (faceted look of the objects), and "gouraud" (linear interpolation
     of the lighting effects between the vertices).  For 'patch'
     objects, the normals must be set manually (property
     "VertexNormals").


The VertexNormals property for patch objects is controlled by the  VertexNormalsMode property.  You might try the following in Matlab.


close all
load ('patch.mat')
p = patch (fv, 'VertexNormalsMode', 'manual');
vn = get (p, 'VertexNormals')  % Is this empty?
light (gca)
view (gca, 3)


Alternatively, you could grab the vertexnormals and later use them in Octave


close all
load ('patch.mat')
p = patch (fv);
vn = get (p, 'VertexNormals');
save vn.mat vn


And then in Octave


close all
load patch.mat
load vn.mat
p = patch (hax, fv, 'FaceAlpha', 1.0, 'FaceColor', 'r', 'EdgeColor', 'none');
set (p, 'VertexNormals', vn);
light (gca);
view (gca, 3);




(file #44203, file #44204)

Rik <rik5>
Group administrator
Mon 21 May 2018 03:32:30 PM UTC, original submission:  


The light function is supposed to add lighting to a 3D plot. I have found a case where the light function seems to have no effect no matter what I do. I have attached a data file "shape_data.mat" and a script, which uses it to demonstrate the problem.

I have also attached images and figures with the expected output from Matlab, and the actual output from Octave.

The examples in the documentation for light do work for me as expected.

I wasn't able to reduce the problem any further, the attached data is essentially an stl file that has been loaded.

I'm using the stable dev branch

Richard <crobar>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #44203:  patch.mat added by rik5 (13KiB - application/octet-stream)
file #44204:  tst_light.m added by rik5 (145B - text/x-matlab)
file #44197:  shape_data.mat added by crobar (14KiB - application/octet-stream)
file #44193:  test_light.m added by crobar (2KiB - text/x-objcsrc)
file #44194:  how_it_should_look.png added by crobar (22KiB - image/png)
file #44196:  how_it_looks_in_octave.ofig added by crobar (286KiB - application/octet-stream)

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by crobar (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 18 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-21 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-07-12 mmuetzel Dependencies- Depends on bugs #54024
    2018-06-04 mmuetzel StatusConfirmed Ready For Test
    2018-05-29 mmuetzel Dependencies- Depends on bugs #51875
    2018-05-24 mmuetzel Operating SystemGNU/Linux Any
    2018-05-24 mmuetzel Dependencies- Depends on patch #8951
    2018-05-24 mmuetzel Operating SystemGNU/Linux Any
    2018-05-23 rik5 Attached File- Added patch.mat, #44203
        Attached File- Added tst_light.m, #44204
        Item GroupIncorrect Result Matlab Compatibility
        StatusNone Confirmed
        Summary'light' function not working for some plots 'light' function not working for patch objects
    2018-05-21 crobar Attached File- Added shape_data.mat, #44197
    2018-05-21 crobar Attached File- Added test_light.m, #44193
        Attached File- Added how_it_should_look.png, #44194
        Attached File- Added how_it_looks_in_octave.png, #44195
        Attached File- Added how_it_looks_in_octave.ofig, #44196

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code