Wrong UV texture coordinates when importing VRML file #39596

Closed
opened 2014-04-04 18:10:53 +02:00 by Guillaume Raffy · 10 comments

System Information
MacOSX 10.6.8 on Apple MacBook 6,1

Blender Version
Broken: 2.70 19e627c

Short description of error
The VRML importer provided as an add-on with blender doesn't import texture coordinates properly : the texture coordinates indices are off by 1.

Exact steps for others to reproduce the error
- start blender
- import a VRML scene that contains texture nodes (for example, fig6.vrml that I uploaded with the case #39594 : once the fix to #39594 is applied, we can see in blender that the texture doesn't display properly (the 4 texture coordinates are off by 1), although this scene is displayed properly with the FreeWRL software)

I attached the patch that I made. This patch fixes this bug, but I beleive that there are some other similar bugs remaining, as this bug seems to have been introduced in an attempt to fix bug blender/blender#18329, as it was tagged with the string 'EEKADOODLE'

texcoords_patch_to_v20131007.patch

texcoords_patch_to_v20131007.unifiedpatch

**System Information** MacOSX 10.6.8 on Apple MacBook 6,1 **Blender Version** Broken: 2.70 19e627c **Short description of error** The VRML importer provided as an add-on with blender doesn't import texture coordinates properly : the texture coordinates indices are off by 1. **Exact steps for others to reproduce the error** - start blender - import a VRML scene that contains texture nodes (for example, fig6.vrml that I uploaded with the case #39594 : once the fix to #39594 is applied, we can see in blender that the texture doesn't display properly (the 4 texture coordinates are off by 1), although this scene is displayed properly with the FreeWRL software) I attached the patch that I made. This patch fixes this bug, but I beleive that there are some other similar bugs remaining, as this bug seems to have been introduced in an attempt to fix bug blender/blender#18329, as it was tagged with the string 'EEKADOODLE' [texcoords_patch_to_v20131007.patch](https://archive.blender.org/developer/F83943/texcoords_patch_to_v20131007.patch) [texcoords_patch_to_v20131007.unifiedpatch](https://archive.blender.org/developer/F83944/texcoords_patch_to_v20131007.unifiedpatch)

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @graffy

Added subscriber: @graffy

Added subscriber: @ThomasDinges

Added subscriber: @ThomasDinges

Added subscriber: @jonim8or

Added subscriber: @jonim8or

Are you sure the UVs in your file fig6.vrml are correct? because the uvs from the laetetia model http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/_pages/page23.html appear to be imported fine. (and get broken with your version)

Are you sure the UVs in your file fig6.vrml are correct? because the uvs from the laetetia model http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/_pages/page23.html appear to be imported fine. (and get broken with your version)

To be honest, I'm not 100% percent sure that fig6.vrml has correct UVs (this vrml file has been generated by mayavi, which is based on vtk, so there might well be a bug in their code). The only reason that makes me think that fig6.vrml is correct is that the UVs look fine when loaded into FreeWRL (http://en.wikipedia.org/wiki/FreeWRL), which seems serious enough...

The Laetetia model http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/_pages/page23.html appears fine in FreeWRL, which seems to confirm that this model contains proper vrml.

As a result, it seems that my patch is suboptimal : it breaks laetitia import while it fixes fig6.vrml.

On a side note when made my 'fix', I noticed that a dummy texture coordinates pair was added to the list of textures coordinates in order to fix the 1-based indices issue. This is quite messy and I don't think this is necessary. Unless I overlooked something, this issue can be solved solely by using additions to UV coordinates indices (keep all python lists 0-based, and adapt indices only at the vrml parsing stage if vrml's indices are 1-based)

To be honest, I'm not 100% percent sure that fig6.vrml has correct UVs (this vrml file has been generated by mayavi, which is based on vtk, so there might well be a bug in their code). The only reason that makes me think that fig6.vrml is correct is that the UVs look fine when loaded into FreeWRL (http://en.wikipedia.org/wiki/FreeWRL), which seems serious enough... The Laetetia model http://www.web3d.org/x3d/content/examples/Basic/StudentProjects/_pages/page23.html appears fine in FreeWRL, which seems to confirm that this model contains proper vrml. As a result, it seems that my patch is suboptimal : it breaks laetitia import while it fixes fig6.vrml. On a side note when made my 'fix', I noticed that a dummy texture coordinates pair was added to the list of textures coordinates in order to fix the 1-based indices issue. This is quite messy and I don't think this is necessary. Unless I overlooked something, this issue can be solved solely by using additions to UV coordinates indices (keep all python lists 0-based, and adapt indices only at the vrml parsing stage if vrml's indices are 1-based)

I really wonder if the tex coords are 1-based. From the vrml specification I understand that they are 0-based:

 If the greatest index in the coordIndex field is N, then the Coordinate node must contain N+1 coordinates (indexed as 0-N)

That should also go for the vertex colors, according to the specification. But I guess there's a reason why the eekadoodle was added.

In my version of the importer #38261 I have removed the dummy entry for uvs, and the "+ 1" that was done when referring to them. And it seems to work (with the laetitia model).

I really wonder if the tex coords are 1-based. From [the vrml specification](http://graphcomp.com/info/specs/sgi/vrml/spec/part1/nodesRef.html#IndexedFaceSet) I understand that they are 0-based: ``` If the greatest index in the coordIndex field is N, then the Coordinate node must contain N+1 coordinates (indexed as 0-N) ``` That should also go for the vertex colors, according to the specification. But I guess there's a reason why the eekadoodle was added. In my version of the importer #38261 I have removed the dummy entry for uvs, and the "+ 1" that was done when referring to them. And it seems to work (with the laetitia model).
Member

Added subscriber: @BrendonMurphy

Added subscriber: @BrendonMurphy
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Brendon Murphy self-assigned this 2016-01-08 07:46:08 +01:00
Member

closing as archived, no activity 1.5 years

closing as archived, no activity 1.5 years
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 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-addons#39596
No description provided.