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

Closed
opened 9 years ago by willi-2 · 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.
Poster

Changed status to: 'Open'

Changed status to: 'Open'
Poster

Added subscriber: @willi-2

Added subscriber: @willi-2
kjym3 was assigned by ideasman42 9 years ago
kjym3 commented 9 years ago
Collaborator

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
kjym3 closed this issue 9 years ago
kjym3 commented 9 years ago
Collaborator

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.
Poster

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!
kjym3 commented 9 years ago
Collaborator

Added subscriber: @ideasman42

Added subscriber: @ideasman42
kjym3 commented 9 years ago
Collaborator

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.
kjym3 commented 9 years ago
Collaborator

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'
kjym3 reopened this issue 9 years ago
Poster

"...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.
kjym3 removed their assignment 9 years ago
ideasman42 was assigned by kjym3 9 years ago
kjym3 commented 9 years ago
Collaborator

Added subscriber: @kjym3

Added subscriber: @kjym3
kjym3 commented 9 years ago
Collaborator

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.
Owner

@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`... ?
ideasman42 removed their assignment 9 years ago
kjym3 was assigned by ideasman42 9 years ago
kjym3 commented 9 years ago
Collaborator

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?
Owner

@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*
kjym3 commented 9 years ago
Collaborator

@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.
kjym3 commented 9 years ago
Collaborator

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
kjym3 closed this issue 9 years ago
kjym3 commented 9 years ago
Collaborator

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/Collada
Interest/Compositing
Interest/Core
Interest/Cycles
Interest/Dependency Graph
Interest/Development Management
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/Modeling
Interest/Modifiers
Interest/Motion Tracking
Interest/Nodes & Physics
Interest/Overrides
Interest/Performance
Interest/Performance
Interest/Physics
Interest/Pipeline, Assets & I/O
Interest/Platforms, Builds, Tests & Devices
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
legacy module/Animation & Rigging
legacy module/Core
legacy module/Development Management
legacy module/Eevee & Viewport
legacy module/Grease Pencil
legacy module/Modeling
legacy module/Nodes & Physics
legacy module/Pipeline, Assets & IO
legacy module/Platforms, Builds, Tests & Devices
legacy module/Python API
legacy module/Rendering & Cycles
legacy module/Sculpt, Paint & Texture
legacy module/Triaging
legacy module/User Interface
legacy module/VFX & Video
legacy project/1.0.0-beta.2
legacy project/Asset Browser (Archived)
legacy project/BF Blender: 2.8
legacy project/BF Blender: After Release
legacy project/BF Blender: Next
legacy project/BF Blender: Regressions
legacy project/BF Blender: Unconfirmed
legacy project/Blender 2.70
legacy project/Code Quest
legacy project/Datablocks and Libraries
legacy project/Eevee
legacy project/Game Animation
legacy project/Game Audio
legacy project/Game Data Conversion
legacy project/Game Engine
legacy project/Game Logic
legacy project/Game Physics
legacy project/Game Python
legacy project/Game Rendering
legacy project/Game UI
legacy project/GPU / Viewport
legacy project/GSoC
legacy project/Infrastructure: Websites
legacy project/LibOverrides - Usability and UX
legacy project/Milestone 1: Basic, Local Asset Browser
legacy project/Nodes
legacy project/OpenGL Error
legacy project/Papercut
legacy project/Pose Library Basics
legacy project/Retrospective
legacy project/Tracker Curfew
legacy project/Wintab High Frequency
Meta/Good First Issue
Meta/Papercut
migration/requires-manual-verification
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 & Devices
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 Information 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

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#39669
Loading…
There is no content yet.