سؤال

I automatically generate texture for 3D mesh where each triangle face has it associate triangle in a texture file. It's working but there are visible black edges while rendering. (Not only on Unity)

Why are there black edges? And how can I automatically get rid of them?

Rendering Cube rendering

Texture: cube.obj.png Texture

cube.obj

mtllib cube.mtl

####
# Vertices
v 0.5 0.5 0.5
v -0.5 0.5 0.5
v 0.5 -0.5 0.5
v -0.5 -0.5 0.5
v 0.5 0.5 -0.5
v -0.5 0.5 -0.5
v 0.5 -0.5 -0.5
v -0.5 -0.5 -0.5
# 8 vertices
vn 0.57735 0.57735 0.57735
vn -0.33333 0.66667 0.66667
vn 0.66667 -0.33333 0.66667
vn -0.66667 -0.66667 0.33333
vn 0.66667 0.66667 -0.33333
vn -0.66667 0.33333 -0.66667
vn 0.33333 -0.66667 -0.66667
vn -0.57735 -0.57735 -0.57735
# 36 vertex textures in submesh 0
vt 0 1
vt 0.33301 0.66699
vt 0 0.66699
vt 0.33301 0.66797
vt 0.00097656 1
vt 0.33301 1
vt 0.33301 1
vt 0.66602 0.66699
vt 0.33301 0.66699
vt 0.66602 0.66797
vt 0.33398 1
vt 0.66602 1
vt 0.66602 1
vt 0.99902 0.66699
vt 0.66602 0.66699
vt 0.99902 0.66797
vt 0.66699 1
vt 0.99902 1
vt 0 0.66699
vt 0.33301 0.33398
vt 0 0.33398
vt 0.33301 0.33496
vt 0.00097656 0.66699
vt 0.33301 0.66699
vt 0.33301 0.66699
vt 0.66602 0.33398
vt 0.33301 0.33398
vt 0.66602 0.33496
vt 0.33398 0.66699
vt 0.66602 0.66699
vt 0.66602 0.66699
vt 0.99902 0.33398
vt 0.66602 0.33398
vt 0.99902 0.33496
vt 0.66699 0.66699
vt 0.99902 0.66699
# The material will be used for mesh 0
usemtl material
# Faces
f 1/1/1 2/2/2 3/3/3
f 4/4/4 3/5/3 2/6/2
f 1/7/1 3/8/3 5/9/5
f 7/10/7 5/11/5 3/12/3
f 1/13/1 5/14/5 2/15/2
f 6/16/6 2/17/2 5/18/5
f 8/19/8 6/20/6 7/21/7
f 5/22/5 7/23/7 6/24/6
f 8/25/8 7/26/7 4/27/4
f 3/28/3 4/29/4 7/30/7
f 8/31/8 4/32/4 6/33/6
f 2/34/2 6/35/6 4/36/4

cube.mtl

newmtl material
Ka 0.2 0.2 0.2
Kd 0.8 0.8 0.8
Ks 1 1 1
d 1
Ns 0
illum 2
map_Kd cube.obj.png
هل كانت مفيدة؟

المحلول

Looks like it's caused by linear interpolation of texels. Try to extend colored pixels in texture by 1px (duplicate last colored line of pixels and place it on edge of black area).

In general it's known issue. To prevent it artists should paint some extra area around polygon edges in texture.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top