Add generic precision option for text-based formats exporters (e.g. X3D, OBJ...) #51865
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
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
10 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#51865
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
io_scene_x3d importer/exporter texture coordinate precision is inadequate for some applications.
The x3d importer/exporter is hardwired to 4 decimal digit precision in generated texture coordinates.
For example, a finely meshed filleted edge on a large object with a single texture could easily have coordinate spacing in (u,v) of less than 1x10^-4, in which case you get a (u,v) space triangle with two vertices that have identical coordinates in the file, and thus zero area, etc. etc. which makes for all sorts of potential problems when the file is read back in.
The relevant lines from https://developer.blender.org/diffusion/BA/browse/master/io_scene_x3d/export_x3d.py
are:
813: fw('%.4f %.4f ' % x3d_v- [x][slot_uv])
and
931: fw('%.4f %.4f ' % uv[:])
Obviously adjusting the precision to (say) 6 digits is a trivial modification.
Here is a patch that makes the precision default to 6, but also be adjustable:
io_scene_x3d.patch
Changed status to: 'Open'
Added subscriber: @sdh4
Added subscriber: @mont29
Thanks for the report, but there is no bug here, textual format will always have limited precision in their values…
Tweaking the amount of precision here (which is a tradeoff between precision and size of generated file) could be nice to add in a generic way for all exporters handling text-based format (can of OBJ at least, others for sure) is a nice and quite simple TODO though (add generic option, and use it to generate a float printf template…).
X3D texture coordinate precision is inadequate for some applications.to Add generic precision option for text-based formats exporters (e.g. X3D, OBJ...)Added subscriber: @JohnRoper
What needs to be done here? I would like to help, but I'm not exactly sure what the final result should be.
Added subscriber: @alourenco
Hey John. Are you taking care of this one?
I'd like to try, but still not sure what the goal is?
I am starting now, so I am not the best person to answer you. Still, as I understood, the idea is to give the user the option to define a float precision on export, because certain applications don't work with certain float precision. But you better ask someone with more experience in IRC to confirm this.
Added subscriber: @ideasman42
Not sure this is a good quick hack - mainly because it's quite a detailed option - should all ascii formats have precision for UV's and verts, ... normals too?
Probably if there are cases precision needs to be increased - we can increase it and not add too many options to exporters.
Added subscriber: @brecht
I suggest to use
%.7g
. It will ensure you have 7 digits of precision on both sides of the decimal combined, likefloat
values have. For very small or large numbers it switches to scientific notation.@brecht LGTM, although think this is only needed for UV's and vertices, think normals can be left at 4 (
%.4g
is fine too).Added subscriber: @brutzman
Added subscriber: @shimanzhang2000
I would like to take this task!
Just wondering: one of the above comments suggested changing the precision of all fields to %.7g. Are we still following this, or just the UV's and vertices. Also, should import also be changed?
suggest that trailing zeroes and trailing decimal points get removed as well to reduce file-size bloat.
@shimanzhang2000, hard to say if it should be all fields. @ideasman42 suggested
%.7g
for uvs and vertices, and%.4g
for normals. I think most other should be%.7g
too, but you need to look at it case by case if it makes sense.Import would not be affected as far as I know.
@brutzman,
%g
does that.Added subscriber: @propersquid
Added subscriber: @Marcelo-Amaral-Ferrante
Hi,
I made a patch to easily change precision, https://developer.blender.org/D7899
Hi,
I made a patch to easily change precision, https://developer.blender.org/D7899
Dont know how to proceed from now.