Freestyle: Curve with extrude>0 causes warnings in console #39669

Closed
opened 2014-04-10 01:51:54 +02:00 by Willi · 17 comments

System Information
Win7/64

Blender Version
Broken: all (since 2.67)

Short description of error
If a 2D curve is extruded and freestyle is enabled, there are many warnings like these in the console when rendering:

Warning: edge 0 - 1 appears twice, correcting
Warning: edge 158 - 159 appears twice, correcting
Warning: edge 1 - 2 appears twice, correcting

Exact steps for others to reproduce the error
Open Freestyle_warnings.blend, render, and look in the console. The render result might be ok, but a warning says there's something wrong or should be improved.

**System Information** Win7/64 **Blender Version** Broken: all (since 2.67) **Short description of error** If a 2D curve is extruded and freestyle is enabled, there are many warnings like these in the console when rendering: ``` Warning: edge 0 - 1 appears twice, correcting Warning: edge 158 - 159 appears twice, correcting Warning: edge 1 - 2 appears twice, correcting ``` **Exact steps for others to reproduce the error** Open [Freestyle_warnings.blend](https://archive.blender.org/developer/F84397/Freestyle_warnings.blend), render, and look in the console. The render result might be ok, but a warning says there's something wrong or should be improved.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @willi-2

Added subscriber: @willi-2
Tamito Kajiyama was assigned by Campbell Barton 2014-04-10 04:24:20 +02:00

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Thank you for filing the report.

The reported problem is not considered a bug. The series of warnings is intended to inform users of potential problems that exist in the input scene data.

To my knowledge, extruded curves contain many duplicated vertices and edges. Freestyle tries to remove them to polish mesh geometry for better line rendering quality. The warnings tell you that there are duplicated edges in the mesh data.

If you convert the curve object into a mesh and apply the Remove Doubles operation to it, then the warnings won't show up.

Thank you for filing the report. The reported problem is not considered a bug. The series of warnings is intended to inform users of potential problems that exist in the input scene data. To my knowledge, extruded curves contain many duplicated vertices and edges. Freestyle tries to remove them to polish mesh geometry for better line rendering quality. The warnings tell you that there are duplicated edges in the mesh data. If you convert the curve object into a mesh and apply the Remove Doubles operation to it, then the warnings won't show up.
Author

Ok, accepted that it's not a bug. Though I'd like to know why there's no warning after conversion to a mesh even without removing doubles. Does the freestyle component get a curve object as input, or does Blender first convert the curve to a mesh before passing it to the freestyle component? If it's the latter, I don't understand why there's no warning after I convert the curve to a mesh. (maybe only a curious programmer can ask this, but to me the difference doesn't make sense)
Thanks for looking into it anyway!

Ok, accepted that it's not a bug. Though I'd like to know why there's no warning after conversion to a mesh even without removing doubles. Does the freestyle component get a curve object as input, or does Blender first convert the curve to a mesh before passing it to the freestyle component? If it's the latter, I don't understand why there's no warning after I convert the curve to a mesh. (maybe only a curious programmer can ask this, but to me the difference doesn't make sense) Thanks for looking into it anyway!

Added subscriber: @ideasman42

Added subscriber: @ideasman42

You are right, and I was overlooking the fact that the warnings could be suppressed by just converting the curve into a mesh without removing doubles.

Freestyle receives from Blender a set of faces (triangles and quads). Curves are converted into faces by the Blender Internal (BI) rendering engine, so Freestyle has nothing to do with the conversion.

A closer look into the issue revealed a subtle difference between the manual curve-to-mesh conversion and the automatic conversion by the BI with regard to the normal of filled faces at both ends of extrusion. With the manual conversion, the filled faces have a normal in the outward direction as expected. With the automatic conversion, their normals are flipped and in the inward direction for some unknown reason. These flipped face normals cause a discontinuity of surface which then leads to the warnings of duplicated edges in Freestyle.

Now the issue has turned out to be in the automatic curve-to-mesh conversion whose result is inconsistent with the manual conversion. Note that this issue is unlikely to result in negative visual artifacts, because it is usually okay to have separate filled faces from the surface made along the extent of extrusion. But consistency is always nice to have.

Campbell, could you please take a look at the difference in the normals of filled faces documented above? I would file a separate issue report if appropriate.

You are right, and I was overlooking the fact that the warnings could be suppressed by just converting the curve into a mesh without removing doubles. Freestyle receives from Blender a set of faces (triangles and quads). Curves are converted into faces by the Blender Internal (BI) rendering engine, so Freestyle has nothing to do with the conversion. A closer look into the issue revealed a subtle difference between the manual curve-to-mesh conversion and the automatic conversion by the BI with regard to the normal of filled faces at both ends of extrusion. With the manual conversion, the filled faces have a normal in the outward direction as expected. With the automatic conversion, their normals are flipped and in the inward direction for some unknown reason. These flipped face normals cause a discontinuity of surface which then leads to the warnings of duplicated edges in Freestyle. Now the issue has turned out to be in the automatic curve-to-mesh conversion whose result is inconsistent with the manual conversion. Note that this issue is unlikely to result in negative visual artifacts, because it is usually okay to have separate filled faces from the surface made along the extent of extrusion. But consistency is always nice to have. Campbell, could you please take a look at the difference in the normals of filled faces documented above? I would file a separate issue report if appropriate.

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'
Author

"...whose result is inconsistent with the manual conversion"
Something like this was my suspicion. Thanks for the explanation in a closed thread. Very much appreciated.

"...whose result is inconsistent with the manual conversion" Something like this was my suspicion. Thanks for the explanation in a closed thread. Very much appreciated.
Tamito Kajiyama removed their assignment 2014-04-24 16:52:42 +02:00
Campbell Barton was assigned by Tamito Kajiyama 2014-04-24 16:52:42 +02:00

Added subscriber: @kjym3

Added subscriber: @kjym3

Campbell, could you please take a look at the reported problem in curve-to-mesh conversion? It looks like a general issue not specific to Freestyle.

Campbell, could you please take a look at the reported problem in curve-to-mesh conversion? It looks like a general issue not specific to Freestyle.

@kjym3

I checked the mesh and its not making duplicate edges,

At least this works as expected.

  mesh = bpy.context.object.to_mesh(bpy.context.scene, apply_modifiers=True, settings='PREVIEW')
  mesh.validate(True)
# this will print duplicate edges.

I expect this is caused by freestyle loading ObjectRen, VlakRen... ?

@kjym3 I checked the mesh and its not making duplicate edges, At least this works as expected. ``` mesh = bpy.context.object.to_mesh(bpy.context.scene, apply_modifiers=True, settings='PREVIEW') mesh.validate(True) ``` # this will print duplicate edges. I expect this is caused by freestyle loading `ObjectRen`, `VlakRen`... ?
Campbell Barton removed their assignment 2014-04-25 12:19:15 +02:00
Tamito Kajiyama was assigned by Campbell Barton 2014-04-25 12:19:15 +02:00

I managed to visualize the curve-to-mesh conversion inconsistency in question.

The attached .blend file below renders a cube in two colors: front faces in blue, and back faces in red.

to_mesh.blend

When the cube is represented by an extruded 2D curve, the face filling the Front of the extruded curve appears in red.

to_mesh_1.png

When the curve is converted into a mesh, the same face appears in blue. That is, the face normal is flipped.

to_mesh_2.png

This difference is what I was trying to highlight in a previous comment of mine (link ):

A closer look into the issue revealed a subtle difference between the manual curve-to-mesh conversion and the automatic conversion by the BI with regard to the normal of filled faces at both ends of extrusion. With the manual conversion, the filled faces have a normal in the outward direction as expected. With the automatic conversion, their normals are flipped and in the inward direction for some unknown reason. These flipped face normals cause a discontinuity of surface which then leads to the warnings of duplicated edges in Freestyle.

Now the issue has turned out to be in the automatic curve-to-mesh conversion whose result is inconsistent with the manual conversion.

Note that flipped face normals are the problem, and not edge duplicates.

@ideasman42, I was unable to track down the cause of the documented issue. Should I file this as a bug?

I managed to visualize the curve-to-mesh conversion inconsistency in question. The attached .blend file below renders a cube in two colors: front faces in blue, and back faces in red. [to_mesh.blend](https://archive.blender.org/developer/F88902/to_mesh.blend) When the cube is represented by an extruded 2D curve, the face filling the Front of the extruded curve appears in red. ![to_mesh_1.png](https://archive.blender.org/developer/F88903/to_mesh_1.png) When the curve is converted into a mesh, the same face appears in blue. That is, the face normal is flipped. ![to_mesh_2.png](https://archive.blender.org/developer/F88905/to_mesh_2.png) This difference is what I was trying to highlight in a previous comment of mine ([link ](https://developer.blender.org/T39669#10)): > A closer look into the issue revealed a subtle difference between the manual curve-to-mesh conversion and the automatic conversion by the BI with regard to the normal of filled faces at both ends of extrusion. With the manual conversion, the filled faces have a normal in the outward direction as expected. With the automatic conversion, their normals are flipped and in the inward direction for some unknown reason. These flipped face normals cause a discontinuity of surface which then leads to the warnings of duplicated edges in Freestyle. > > Now the issue has turned out to be in the automatic curve-to-mesh conversion whose result is inconsistent with the manual conversion. Note that flipped face normals are the problem, and not edge duplicates. @ideasman42, I was unable to track down the cause of the documented issue. Should I file this as a bug?

@kjym3, yep, this does look like a bug on its own.

however the winding direction of the face is correct AFAICS,

  • when you convert to a mesh the face points the right way
  • when enabling backface culling in OpenGL, it looks correct too.

So somehow the normal is pointing the wrong way when rendering (which is very strange)

Note: BI has its own code to convert displists to faces, perhaps bug is there

@kjym3, yep, this does look like a bug on its own. however the winding direction of the face is correct AFAICS, - when you convert to a mesh the face points the right way - when enabling backface culling in OpenGL, it looks correct too. So somehow the normal is pointing the wrong way when rendering (which is very strange) *Note: BI has its own code to convert displists to faces, perhaps bug is there*

@ideasman42,
I made an attempt to fix the wrong normals and submitted a patch: D532. Flipping of normals (or the z-up direction to compute the normals) is found here and there, so I tried to make them consistent. Tested cases include:

  • a 2D extruded curve with both ends filled;
  • the extruded curve plus a modifier (tested with Triangulate);
  • the extruded curve with the Z scale set to -1;
  • a mesh converted from the extruded curve in all the 3 cases above.
    The same tests were done with a 3D curve with filled caps. None of the tests resulted in a wrong normal (no warnings from Freestyle either). Hope this helps.
@ideasman42, I made an attempt to fix the wrong normals and submitted a patch: [D532](https://archive.blender.org/developer/D532). Flipping of normals (or the z-up direction to compute the normals) is found here and there, so I tried to make them consistent. Tested cases include: * a 2D extruded curve with both ends filled; * the extruded curve plus a modifier (tested with Triangulate); * the extruded curve with the Z scale set to -1; * a mesh converted from the extruded curve in all the 3 cases above. The same tests were done with a 3D curve with filled caps. None of the tests resulted in a wrong normal (no warnings from Freestyle either). Hope this helps.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Fix D532 was done by commit f8554ed61a. Thank you @ideasman42 for the code review!

Fix [D532](https://archive.blender.org/developer/D532) was done by commit f8554ed61a. Thank you @ideasman42 for the code review!
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#39669
No description provided.