My obj file contains two objects that are body and floor.
body.jpg and floor.png files should be mapped to body and floor respectively.
Body part renders OK.
But, floor portion always renders in black.
In particular, floor.png file contains shadow and the rest area is transparent and floor mesh is a simple plain with just 4 vertices.
Any idea why its floor renders always in black?
Here is code snipet and info from obj and mtl files.
let scatterFuncFloor = MDLScatteringFunction()
let floorProperty = MDLMaterialProperty(name: floorTextureFile, semantic: MDLMaterialSemantic.baseColor, url: floorTextureURL)
let floorMaterial = MDLMaterial(name: NOLOC("FLOOR"), scatteringFunction: scatterFuncFloor)
floorMaterial.setProperty(floorProperty)
.............
for submesh in modelObj.submeshes! {
if let submesh = submesh as? MDLSubmesh {
if (index == 0) { // Floor
submesh.material = floorMaterial
print(" submesh[0] name:", submesh.name)
index += 1
}
else { // body
submesh.material = material
print(" submesh[1] name:", submesh.name)
}
}
}
Here is material info.
-----------------------------------------------
newmtl FLOOR
Kd 0.800000 0.800000 0.800000
illum 1
map_Kd floor.png
map_d floor.png
newmtl BODY
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
illum 1
map_Ka body.jpg
map_Kd body.jpg
---------------------------------------------------
From obj file
---------------------------------------------
o Plane.1
v -10 0 10
v 10 0 10
v -10 0 -10
v 10 0 -10
# 4 vertices
vt 0.00000 0.00000
vt 0.00000 1.00000
vt 1.00000 1.00000
vt 1.00000 0.00000
# 4 texture coordinates
vn 0 1 -0
# 1 vertex normals
usemtl FLOOR
f 2/4/1 4/3/1 3/2/1 1/1/1
# 1 facets
---------------------------------------------------
PS:
By the way,
If I put the obj into SCN file and load the scene from SCN file, then it renders the floor OK, though.