[bug] island_margin in bpy.ops.uv.smart_project seems to have no effect #53997

Closed
opened 2018-02-04 16:04:35 +01:00 by max brunner · 10 comments

System Information
Windows 10X64, GTX1080

Blender Version
Broken: 2.79 (+a)
Worked: previous version (2.76 ?)

The island_margin value seems to have no/minor effect in the new version of Blender when using a command line python script (to add a lightmap to meshes in a fbx file).
bpy.ops.uv.smart_project(angle_limit=66.0, island_margin=0.0, user_area_weight=0.0, use_aspect=True)
When importing the fbx in Unreal, compared to an earlier version of Blender, changing the value for island_margin from 0 to 1 has no to really minor effect.

Exact steps for others to reproduce the error
on the command line using a python script; open an fbx, add a 2nd uv channel, use the smart_project command from above, save as a new fbx file and open in a fbx viewer where you can see the uv layout.

**System Information** Windows 10X64, GTX1080 **Blender Version** Broken: 2.79 (+a) Worked: previous version (2.76 ?) The island_margin value seems to have no/minor effect in the new version of Blender when using a command line python script (to add a lightmap to meshes in a fbx file). bpy.ops.uv.smart_project(angle_limit=66.0, **island_margin=0.0**, user_area_weight=0.0, use_aspect=True) When importing the fbx in Unreal, compared to an earlier version of Blender, changing the value for island_margin from 0 to 1 has no to really minor effect. **Exact steps for others to reproduce the error** on the command line using a python script; open an fbx, add a 2nd uv channel, use the smart_project command from above, save as a new fbx file and open in a fbx viewer where you can see the uv layout.
Author

Added subscriber: @mrBrown13

Added subscriber: @mrBrown13

Added subscriber: @cyaoeu

Added subscriber: @cyaoeu

By default it uses units as a measurement so in Blender default scale island_margin 0.0 means 0m and island_margin 1 means 1m. You mentioned UE4 so I'm assuming you're using a scene scale of 0.01 for skeletal mesh compatibility.

If you use a scene scale of 0.01 Blender assumes all of your typed units are now in centimeters instead of meters. This means that in this operator island_margin 0.0 now means 0cm and island_margin 1 means 1cm. So, in other terms, where in default scale it would be 0 and 100cm it is now 0 and 1cm meaning you get a 100 times smaller margin.

It's hard to say whether this is a bug or not, it could be a design (bad design) issue instead. But you can fix it with a workaround by opening the file (located in your Blender software folder\2.79\scripts\startup\bl_operators\uvcalc_smart_project.py) and search for "Island Margin" until you find the FloatProperty. Inside it you can change the max value from 1.0 to 100.0. That way it will behave as the Blender default even in the changed scene scale.

By default it uses units as a measurement so in Blender default scale island_margin 0.0 means 0m and island_margin 1 means 1m. You mentioned UE4 so I'm assuming you're using a scene scale of 0.01 for skeletal mesh compatibility. If you use a scene scale of 0.01 Blender assumes all of your typed units are now in centimeters instead of meters. This means that in this operator island_margin 0.0 now means 0cm and island_margin 1 means 1cm. So, in other terms, where in default scale it would be 0 and 100cm it is now 0 and 1cm meaning you get a 100 times smaller margin. It's hard to say whether this is a bug or not, it could be a design (bad design) issue instead. But you can fix it with a workaround by opening the file (located in your Blender software folder\2.79\scripts\startup\bl_operators\uvcalc_smart_project.py) and search for "Island Margin" until you find the FloatProperty. Inside it you can change the max value from 1.0 to 100.0. That way it will behave as the Blender default even in the changed scene scale.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

This was caused by fix for #53678.

Not sure this should be considered a bug though.

Since the value is in distance units - applying those using the scenes settings makes sense.

However, the value being modified when called from a script isn't great - perhaps we should only apply scene scaling from the UI, not Python execution. Needs investigation.

Note that the issue was minor, if it's causing problems it might be best to revert it.

This was caused by fix for #53678. Not sure this should be considered a bug though. Since the value is in distance units - applying those using the scenes settings makes sense. However, the value being modified when called from a script isn't great - perhaps we should only apply scene scaling from the UI, not Python execution. Needs investigation. Note that the issue was minor, if it's causing problems it might be best to revert it.

In #53997#483247, @ideasman42 wrote:
This was caused by fix for #53678.

Not sure this should be considered a bug though.

Since the value is in distance units - applying those using the scenes settings makes sense.

However, the value being modified when called from a script isn't great - perhaps we should only apply scene scaling from the UI, not Python execution. Needs investigation.

Note that the issue was minor, if it's causing problems it might be best to revert it.

Are you sure this is caused by that fix? I'm not seeing any difference in behavior with that fix or commenting it out. The 0.01 scene still gives a tiny 1cm margin instead of 1m.

You can test these files, first with 0.01 scene unit scale and second with 1 scene unit scale. Ideally they should give the same result. 0.01scenecube.blend 1scenecube.blend

> In #53997#483247, @ideasman42 wrote: > This was caused by fix for #53678. > > Not sure this should be considered a bug though. > > Since the value is in distance units - applying those using the scenes settings makes sense. > > However, the value being modified when called from a script isn't great - perhaps we should only apply scene scaling from the UI, not Python execution. Needs investigation. > > Note that the issue was minor, if it's causing problems it might be best to revert it. Are you sure this is caused by that fix? I'm not seeing any difference in behavior with that fix or commenting it out. The 0.01 scene still gives a tiny 1cm margin instead of 1m. You can test these files, first with 0.01 scene unit scale and second with 1 scene unit scale. Ideally they should give the same result. [0.01scenecube.blend](https://archive.blender.org/developer/F2129664/0.01scenecube.blend) [1scenecube.blend](https://archive.blender.org/developer/F2129669/1scenecube.blend)
Author

Hi Henrik and Campbell, thanks for looking into this issue. I'm puzzled by the logic of using real units instead of a percentage. Seems strange to me (using lightmap texture sizes of 64/128/256/512).
I modified the uvcalc_smart_project.py and that works for me. Thanks! Should make a note of it in case of future updates of Blender.

There seems to be some inconsistency in the uv scaling in the python methods anyway because yesterday I 'fixed' this issue in the python script by adding to;
bpy.ops.uv.smart_project(angle_limit=66.0, island_margin=myMargin, user_area_weight=0.0, use_aspect=True)

bpy.ops.uv.select_all(action='SELECT')
bpy.ops.uv.pack_islands(rotate=True, margin=myMargin)

By adding those two lines, the scaling of the uvs (even witm small numbers) seems to be as before.

Hi Henrik and Campbell, thanks for looking into this issue. I'm puzzled by the logic of using real units instead of a percentage. Seems strange to me (using lightmap texture sizes of 64/128/256/512). I modified the uvcalc_smart_project.py and that works for me. Thanks! Should make a note of it in case of future updates of Blender. There seems to be some inconsistency in the uv scaling in the python methods anyway because yesterday I 'fixed' this issue in the python script by adding to; bpy.ops.uv.smart_project(angle_limit=66.0, island_margin=myMargin, user_area_weight=0.0, use_aspect=True) bpy.ops.uv.select_all(action='SELECT') bpy.ops.uv.pack_islands(rotate=True, margin=myMargin) By adding those two lines, the scaling of the uvs (even witm small numbers) seems to be as before.

Added subscriber: @midan-3

Added subscriber: @midan-3
Sebastian Parborg self-assigned this 2019-03-04 15:01:04 +01:00

This issue was referenced by 0403a2f785

This issue was referenced by 0403a2f78502193646506f6c9c4529d40af2bc19

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
6 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#53997
No description provided.