Page 1 of 1

CreateMesh mirror texture when shared vertex with other faces

Posted: Wed Mar 06, 2024 2:53 pm
by minimy
Hello, Is there a way to correctly put textures on a mesh created with CreateMesh()?
Let me explain, when you create a mesh and share the vertices with other faces, the faces are rotated or mirrored.

Code: Select all

__v1 __v2 __v3
__|-----|------|
__| face1 | face2 |
v4 |----- |------|v6
__| face3| face4 |
__|-----|------|
__v7 __v8 __v9
face1(v1,v2,v5,v4)
face2(v2,v3,v6,v5)
Here face1 and face2 share v2 and v5, in face2 the texture is the mirror of face1.

How can I avoid this?
If is using material, some body can put an example, please.

Thanks for help!

Re: CreateMesh mirror texture when shared vertex with other faces

Posted: Wed Mar 06, 2024 4:34 pm
by pjay
Your vertices should be unique for each face if each vertex has different texture co'ordinates.

Re: CreateMesh mirror texture when shared vertex with other faces

Posted: Wed Mar 06, 2024 8:46 pm
by minimy
pjay wrote: Wed Mar 06, 2024 4:34 pm Your vertices should be unique for each face if each vertex has different texture co'ordinates.
Hi pjay, thanks for help.
Then the way is AddSubMesh()... but if i use this way to make for example a terrain the speed in fps down from 480 fps in a decent matrix of (256x256) to 38 in a small matrix of (64x64)... i hope must exist a better way to do it.
How you can see is a great diference of speed.

I think the 'trick' will be in material, but i no control still. Im testing with many materials triying to find the good combination.

Any way, thanks for your help.

Re: CreateMesh mirror texture when shared vertex with other faces

Posted: Sat Mar 23, 2024 4:55 pm
by pf shadoko
I'm not sure what you mean.
texture coordinates (UV) are not limited between 0 and 1
if you want it to repeat itself:

UV:
0,0---1,0---2,0
0,1---1,1---2,1
0,2---1,2---2,2