4

I have following problem image gets distorted along the face side (red line). I have a few layers like this on each I have the same distortion. I have double checked UV mapping and both faces have the same 2 UV coordinates for same 2 points. I would paste some code but it is a bit complex UV calculation. I am trying to see if somebody had a similar problem.

enter image description here

Uv mapping for this part (Red line matches picture above) enter image description here

Here is the code for UV calculation but you probably wont be able to find an error there.

calculateNewUvMapping(vertices: Array<Vector3>): Array<Vector2> {
const orderedVertices = _.clone(vertices).reverse();
const newArray: Array<Vector2> = new Array<Vector2>();

const startV3 = orderedVertices[0];
const endV3 = orderedVertices[orderedVertices.length - 1];

const start = new Vector2(startV3.x, startV3.z);
const end = new Vector2(endV3.x, endV3.z);

// Distance between two vertices on scale from 0 to 1
const distanceAlpha = 1 / (orderedVertices.length - 1);

newArray.push(start);
for (let i = 1; i < orderedVertices.length - 1; i++) {
  const newUv = new Vector2();
  const interpolationValue = distanceAlpha * i;
  newUv.lerpVectors(start, end, interpolationValue);
  newArray.push(newUv);
}
newArray.push(end);

return newArray;
}

EDIT: Its not normals calculation.

Dživo Jelić
  • 1,723
  • 3
  • 25
  • 47
  • It is 3D projection we also exported model and opened it in blender uv mapping is same there so we are unsure whats wrong :). Also this bottom romb part is flat two faces are connected but they are forming a plane – Dživo Jelić Nov 27 '18 at 16:53
  • Sorry i meant it is a 3d model not projection – Dživo Jelić Nov 27 '18 at 17:04
  • I am calculating geometry on my own i am creating spherical-ish model and calculating faces and UV – Dživo Jelić Nov 27 '18 at 17:12
  • 4
    @DživoJelić Is this your issue? https://stackoverflow.com/questions/16880015/three-js-with-canvas-renderer-broken-textures – WestLangley Dec 03 '18 at 23:06
  • @WestLangley actually its this and its pretty decent answer but i am going to need some time to try it out. https://gamedev.stackexchange.com/questions/148082/how-can-i-fix-zig-zagging-uv-mapping-artifacts-on-a-generated-mesh-that-tapers/148102#148102?newreg=abe0d6aa9a6242ebb62331e4895228dd – Dživo Jelić Dec 03 '18 at 23:59
  • You sure it's not something simple like a missing perspective correction hint for texture rendering? – Frederik De Ruyck Dec 10 '18 at 16:12
  • @FrederikDeRuyck can you give me an example ? Not quite sure what you mean – Dživo Jelić Dec 12 '18 at 00:16
  • Could it be a similar problem to this? https://stackoverflow.com/questions/15242507/perspective-correct-texturing-of-trapezoid-in-opengl-es-2-0 – Frederik De Ruyck Dec 12 '18 at 08:26

0 Answers0