use_smooth boolean always true after import #109074

Closed
opened 2023-06-17 11:53:26 +02:00 by Sebastian Sille · 10 comments

System Information
Operating system: Windows 11
Graphics card: NVIDIA RTX A2000

Blender Version
Broken: version: 3.6.0 Beta, branch: blender-v3.6-release, commit date: 2023-06-15 19:52, hash: 1c5201b23a
Worked: version: 3.6.0 Alpha, branch: main, commit date: 2023-02-26 23:09, hash: ca2c0da79e

Seems to be related to 5876573e14,
where mesh attribute sharp_face is needed to get flat shaded faces. In bmesh the use_smooth boolean is now true by default.

Short description of error
Importing a 3ds or x3d file wich should be flat shaded is always smooth. polygon.use_smooth flag is always true and can not be changed manually.

Exact steps for others to reproduce the error
Export default cube to x3d and then import again. The formerly flat shaded cube is now smooth shaded.
Import attached .3ds file, it was exported flat shaded without smooth chunk and imported correct in Blender 3.5.1 but incorrect in Blender 3.6

Reference: #104422

**System Information** Operating system: Windows 11 Graphics card: NVIDIA RTX A2000 **Blender Version** Broken: version: 3.6.0 Beta, branch: blender-v3.6-release, commit date: 2023-06-15 19:52, hash: 1c5201b23a3e Worked: version: 3.6.0 Alpha, branch: main, commit date: 2023-02-26 23:09, hash: ca2c0da79eeb Seems to be related to [`5876573e14`](https://projects.blender.org/blender/blender/commit/5876573e14), where mesh attribute `sharp_face` is needed to get flat shaded faces. In bmesh the use_smooth boolean is now true by default. **Short description of error** Importing a 3ds or x3d file wich should be flat shaded is always smooth. polygon.use_smooth flag is always true and can not be changed manually. **Exact steps for others to reproduce the error** Export default cube to x3d and then import again. The formerly flat shaded cube is now smooth shaded. Import attached .3ds file, it was exported flat shaded without smooth chunk and imported correct in Blender 3.5.1 but incorrect in Blender 3.6 Reference: #104422
Sebastian Sille added the
Type
Report
Status
Needs Triage
Priority
Normal
labels 2023-06-17 11:53:27 +02:00
Author
Member

Fixed it by myself: c022b24f4f

Fixed it by myself: [`c022b24f4f`](https://projects.blender.org/blender/blender-addons/commit/c022b24f4f59001138b8f485ff6bd972f852c015)
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-06-17 13:24:24 +02:00
Blender Bot added
Status
Needs Triage
and removed
Status
Archived
labels 2023-06-18 05:06:55 +02:00
Author
Member

Re-opened this issue because my fix did not solve the problem if the 3ds mesh has no smooth chunk. The flat shaded object will be imported with smooth faces by default, like the attached object

Re-opened this issue because my fix did not solve the problem if the 3ds mesh has no smooth chunk. The flat shaded object will be imported with smooth faces by default, like the attached object
Sebastian Sille changed title from use_smooth- boolean always true after import to use_smooth boolean always true after import 2023-06-18 11:23:22 +02:00
Member

Hi, thanks for the report. Can confirm. I've not investigated this yet from code side but perhaps changes in export code are also needed?

Did you check in other visualization software whether faces are smooth shaded or flat?

Seems to be related to 5876573e14, where mesh attribute sharp_face is needed to get flat shaded faces.

@HooglyBoogly ^

Hi, thanks for the report. Can confirm. I've not investigated this yet from code side but perhaps changes in export code are also needed? Did you check in other visualization software whether faces are smooth shaded or flat? > Seems to be related to 5876573e14, where mesh attribute sharp_face is needed to get flat shaded faces. @HooglyBoogly ^
Pratik Borhade added
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-06-19 08:04:12 +02:00
Author
Member

Hi, thanks for the report. Can confirm. I've not investigated this yet from code side but perhaps changes in export code are also needed?

Did you check in other visualization software whether faces are smooth shaded or flat?

Seems to be related to 5876573e14, where mesh attribute sharp_face is needed to get flat shaded faces.

@HooglyBoogly ^

The attached 3ds is flat shaded, it includes no smooth chunk therfore no smoothing info exported

> Hi, thanks for the report. Can confirm. I've not investigated this yet from code side but perhaps changes in export code are also needed? > > Did you check in other visualization software whether faces are smooth shaded or flat? > > > > Seems to be related to 5876573e14, where mesh attribute sharp_face is needed to get flat shaded faces. > > @HooglyBoogly ^ The attached 3ds is flat shaded, it includes no smooth chunk therfore no smoothing info exported
Member

Thanks for the report. 30bf4c0945 fixes the "use_smooth" property, which didn't work correctly when the attribute didn't already exist and you set the value False.

The importer still needs a small change though:

diff --git a/io_scene_3ds/import_3ds.py b/io_scene_3ds/import_3ds.py
index daeda6ee43f..85cc83f13ed 100644
--- a/io_scene_3ds/import_3ds.py
+++ b/io_scene_3ds/import_3ds.py
@@ -449,6 +449,8 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
                     bmesh.polygons[f].use_smooth = True
                 else:
                     bmesh.polygons[f].use_smooth = False
+        else:
+            bmesh.polygons.foreach_set("use_smooth", [False] * len(bmesh.polygons))
 
         if contextMatrix:
             if WORLD_MATRIX:
Thanks for the report. 30bf4c0945d17fad2f78edffe284846f1ec03a9d fixes the "use_smooth" property, which didn't work correctly when the attribute didn't already exist and you set the value `False`. The importer still needs a small change though: ```Diff diff --git a/io_scene_3ds/import_3ds.py b/io_scene_3ds/import_3ds.py index daeda6ee43f..85cc83f13ed 100644 --- a/io_scene_3ds/import_3ds.py +++ b/io_scene_3ds/import_3ds.py @@ -449,6 +449,8 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI bmesh.polygons[f].use_smooth = True else: bmesh.polygons[f].use_smooth = False + else: + bmesh.polygons.foreach_set("use_smooth", [False] * len(bmesh.polygons)) if contextMatrix: if WORLD_MATRIX: ```
Blender Bot added
Status
Archived
and removed
Status
Confirmed
labels 2023-06-20 03:46:33 +02:00
Member

I also committed that fix to the addons repository

I also committed that fix to the addons repository
Author
Member

I also committed that fix to the addons repository

@HooglyBoogly I just wanted to do that, and saw you already did this^^ Is it better to do it like this:

for poly in bmesh.polygons:
   poly.use_smooth = False

instead of this?
bmesh.polygons.foreach_set("use_smooth", [False] * len(bmesh.polygons))

And another question wich is a little off-topic but fits to the inverted topic
i have noticed that many definitions in blender are inverted as opposed to 3ds definitions. (for example roughness -> shininess or alpha ->opacity).
Would it be possible to invert the colors of a texture by adding a new attribute 'invert' as a new feature to the colorspace settings?
I would like to share this idea with developers , is there an area where you can publish this?

> I also committed that fix to the addons repository @HooglyBoogly I just wanted to do that, and saw you already did this^^ Is it better to do it like this: ``` for poly in bmesh.polygons: poly.use_smooth = False ``` instead of this? `bmesh.polygons.foreach_set("use_smooth", [False] * len(bmesh.polygons))` And another question wich is a little off-topic but fits to the inverted topic i have noticed that many definitions in blender are inverted as opposed to 3ds definitions. (for example roughness -> shininess or alpha ->opacity). Would it be possible to invert the colors of a texture by adding a new attribute 'invert' as a new feature to the colorspace settings? I would like to share this idea with developers , is there an area where you can publish this?
Member

Is it better to do it like this:
instead of this?

I doubt it makes much of a difference in this case. The second might be faster but it's also more complex looking.

Would it be possible to invert the colors of a texture by adding a new attribute 'invert' as a new feature to the colorspace settings?

Probably better in my opinion to just invert things once, rather than keeping track of an "invert" setting everywhere in Blender, which would likely have performance effects as well.

>Is it better to do it like this: >instead of this? I doubt it makes much of a difference in this case. The second might be faster but it's also more complex looking. > Would it be possible to invert the colors of a texture by adding a new attribute 'invert' as a new feature to the colorspace settings? Probably better in my opinion to just invert things once, rather than keeping track of an "invert" setting everywhere in Blender, which would likely have performance effects as well.
Author
Member

@HooglyBoogly
I just tried out the recent fixes and noticed that the .x3d add-on still imports a smooth shaded object when it should be flat.
I will check the code this evening, maybe I can fix it - just wanted to point out that there are still some tiny bugs creeping around

@HooglyBoogly I just tried out the recent fixes and noticed that the .x3d add-on still imports a smooth shaded object when it should be flat. I will check the code this evening, maybe I can fix it - just wanted to point out that there are still some tiny bugs creeping around
Author
Member

Fixed .x3d import 4909b7504 ff73491bb2

Fixed .x3d import [`4909b7504`](https://projects.blender.org/blender/blender-addons/commit/4909b750407b0aab6620cb06c36287decd0618d2) [`ff73491bb2`](https://projects.blender.org/blender/blender-addons/commit/ff73491bb29aa8d56b513b8f8f221370f90482f1)
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#109074
No description provided.