Export texture coordinates are wrong after move them in UV Editor #43637

Closed
opened 2015-02-12 04:52:55 +01:00 by Shawn R Fisk · 9 comments

Create a simple cube with texture. 2x2x8
Adjust UI coordinates to have correct ratio. Had move move them around.
Export to collada and the UV coordinates in export are incorrect in the dae file.
See the following:
blender file:beam2.blend
collada export file:beam2.dae

Create a simple cube with texture. 2x2x8 Adjust UI coordinates to have correct ratio. Had move move them around. Export to collada and the UV coordinates in export are incorrect in the dae file. See the following: blender file:[beam2.blend](https://archive.blender.org/developer/F142599/beam2.blend) collada export file:[beam2.dae](https://archive.blender.org/developer/F142600/beam2.dae)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @ShawnFisk

Added subscriber: @ShawnFisk
Member

Added subscriber: @Blendify

Added subscriber: @Blendify
Gaia Clary was assigned by Julian Eisel 2015-02-13 11:36:49 +01:00
Member

Added subscribers: @GaiaClary, @JulianEisel

Added subscribers: @GaiaClary, @JulianEisel
Member

@GaiaClary, is this a known issue/limitation or a real bug?

@GaiaClary, is this a known issue/limitation or a real bug?
Author

Yes, this is a bug. How do I know? I know how bug was created because I had the same issue in my first implementation but test cases failed. Since I could not wait for you to fix. I started a project to read the blender file directly. This is what I found out:

Read Vertex:(generic code) (If figure you do not want to see real implementation).

load mVerts from MVert data section
load mPolys from MPloy data section
load mLoops from MLoop data section

// generate vertex sets for each face.
int faceIdx = 0;
for(MPoly ploy : mPolys) {

    int start = ploy.getLoopstart();
    int count = ploy.getTotloop();
    int end = start + count;
    output  face(faceIdx++)
     for(int i = start;i < end;i++) {
          MLoop loop = l_mLoops.get(i);
          int v = loop.getV();
          MVert vert = mVerts.get(v);
         output values for vert
     }

}

You are doing the following for generation texture mapping coordinates (which seems logical but is wrong).

load mLoopUVs from MLoopUV data section

// Wrongly generate texture UV coordinates for each face, exactly what the python code is doing.
int faceIdx = 0;
for(MPoly ploy : mPolys) {

    int start = ploy.getLoopstart();
    int count = ploy.getTotloop();
    int end = start + count;
    output  face(faceIdx++)
     for(int i = start;i < end;i++) {
          MLoop loop = l_mLoops.get(i);
          int v = loop.getV();
          MLoopUV uv  mLoopUVs.get(v);
         output values for uv
     }

}

This is what is should be in my opinion:

// Correctly generate texture UV coordinates for each face, the fix

for(MPoly ploy : mPolys) {

    int start = ploy.getLoopstart();
    int count = ploy.getTotloop();
    int end = start + count;
    output  face(faceIdx++)
    for(int i = start;i < end;i++) {
       MLoopUV loopUv = mLoopUvs.get(i);
      output loopUv values
    }

}

the MLoopUVs is the UVs for each face, my example a box with each face having two triangles. 6 vertices per side there are 6 sides therefore 36 UV coordinates. The MLoopUV data sections is setup based on the MLoop (start, total), therefore my algorithm reads it correctly. Needless so say, I wrote lots of tooling to figure out the blender format when it comes to UV coordindates.

I hope this help to track down and fix the issue.

Yes, this is a bug. How do I know? I know how bug was created because I had the same issue in my first implementation but test cases failed. Since I could not wait for you to fix. I started a project to read the blender file directly. This is what I found out: Read Vertex:(generic code) (If figure you do not want to see real implementation). load mVerts from MVert data section load mPolys from MPloy data section load mLoops from MLoop data section // generate vertex sets for each face. int faceIdx = 0; for(MPoly ploy : mPolys) { ``` int start = ploy.getLoopstart(); int count = ploy.getTotloop(); int end = start + count; ``` ``` output face(faceIdx++) for(int i = start;i < end;i++) { MLoop loop = l_mLoops.get(i); ``` ``` int v = loop.getV(); MVert vert = mVerts.get(v); output values for vert } ``` } You are doing the following for generation texture mapping coordinates (which seems logical but is wrong). load mLoopUVs from MLoopUV data section // Wrongly generate texture UV coordinates for each face, exactly what the python code is doing. int faceIdx = 0; for(MPoly ploy : mPolys) { ``` int start = ploy.getLoopstart(); int count = ploy.getTotloop(); int end = start + count; ``` ``` output face(faceIdx++) for(int i = start;i < end;i++) { MLoop loop = l_mLoops.get(i); ``` ``` int v = loop.getV(); MLoopUV uv mLoopUVs.get(v); output values for uv } ``` } This is what is should be in my opinion: // Correctly generate texture UV coordinates for each face, the fix for(MPoly ploy : mPolys) { ``` int start = ploy.getLoopstart(); int count = ploy.getTotloop(); int end = start + count; ``` ``` output face(faceIdx++) for(int i = start;i < end;i++) { MLoopUV loopUv = mLoopUvs.get(i); output loopUv values } ``` } the MLoopUVs is the UVs for each face, my example a box with each face having two triangles. 6 vertices per side there are 6 sides therefore 36 UV coordinates. The MLoopUV data sections is setup based on the MLoop (start, total), therefore my algorithm reads it correctly. Needless so say, I wrote lots of tooling to figure out the blender format when it comes to UV coordindates. I hope this help to track down and fix the issue.
Member

I tested this and i could not find an issue with the UV coordinates. The exporter creates the UV vertices as expected. Here is the part of the code that does it:

// export the uv coordinates for the polygon loops
for (int index = 0; index < totpoly; index++) {
	MPoly   *mpoly = mpolys+index;
	MLoopUV *mloop = mloops+mpoly->loopstart;
	for (int j = 0; j < mpoly->totloop; j++) {
		source.appendValues(mloop[j].uv[0], mloop[j].uv[1]);
	}
}

The exported dae file contains:

3 UV coordinates per triangle
12 triangles in cube
36 UV coordinates in total

Please can you explain in which way the UV coordinates are wrong for you? Maybe i misunderstand the issue completely.

As a sidenote: Seam information is get lost during export. But as far as i could see this is because collada does not support seam information (please correct me if i am wrong).

I tested this and i could not find an issue with the UV coordinates. The exporter creates the UV vertices as expected. Here is the part of the code that does it: ``` // export the uv coordinates for the polygon loops for (int index = 0; index < totpoly; index++) { MPoly *mpoly = mpolys+index; MLoopUV *mloop = mloops+mpoly->loopstart; for (int j = 0; j < mpoly->totloop; j++) { source.appendValues(mloop[j].uv[0], mloop[j].uv[1]); } } ``` The exported dae file contains: 3 UV coordinates per triangle 12 triangles in cube 36 UV coordinates in total Please can you explain in which way the UV coordinates are wrong for you? Maybe i misunderstand the issue completely. As a sidenote: Seam information is get lost during export. But as far as i could see this is because collada does not support seam information (please correct me if i am wrong).
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Member

No answer for more than a week -> closed! Sorry, but we have to be very strict in order to keep our bug tracker organized. We can consider reopening after we've got the requested information.

No answer for more than a week -> closed! Sorry, but we have to be very strict in order to keep our bug tracker organized. We can consider reopening after we've got the requested information.
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
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#43637
No description provided.