iOS transparent area with texture rendered in black (obj, scenekit, model io)
up vote
-1
down vote
favorite
obj file has 2 objects - body and floor.
Floor is a simple clear transparent plane with just 4 vertices.
And I applied both PNG (with transparent area) and JPEG textures, but it all renders in black.
I also tried
transparent.contents = UIImage(named:"floor.png")
I don't know how I can render it properly.
I am using two approaches.
- Load obj file via model io then add to scene node.
- Load .scn file where the model'd been added beforehand.
But both didn't work out.
The following is the code that I am using now.
With Model I/O
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)
}
}
}
With .scn file
(In the preview of scn file, it was rendered properly, but not in the app)
let url = URL(fileURLWithPath: dir+"/model.scn")
do {
let scene = try SCNScene(url: url, options: nil)
scene.background.contents = UIColor.white
modelNode = scene.rootNode.childNodes[1]
//modelNode.childNodes[0].geometry?.materials[0].transparencyMode = SCNTransparencyMode.rgbZero
self.autoenablesDefaultLighting = true
self.antialiasingMode = SCNAntialiasingMode.multisampling4X
self.allowsCameraControl = true
self.scene = scene
self.backgroundColor = UIColor.white
}
catch {
print("cannot find or open SCN file")
}
Any idea?
ios textures scenekit modelio
add a comment |
up vote
-1
down vote
favorite
obj file has 2 objects - body and floor.
Floor is a simple clear transparent plane with just 4 vertices.
And I applied both PNG (with transparent area) and JPEG textures, but it all renders in black.
I also tried
transparent.contents = UIImage(named:"floor.png")
I don't know how I can render it properly.
I am using two approaches.
- Load obj file via model io then add to scene node.
- Load .scn file where the model'd been added beforehand.
But both didn't work out.
The following is the code that I am using now.
With Model I/O
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)
}
}
}
With .scn file
(In the preview of scn file, it was rendered properly, but not in the app)
let url = URL(fileURLWithPath: dir+"/model.scn")
do {
let scene = try SCNScene(url: url, options: nil)
scene.background.contents = UIColor.white
modelNode = scene.rootNode.childNodes[1]
//modelNode.childNodes[0].geometry?.materials[0].transparencyMode = SCNTransparencyMode.rgbZero
self.autoenablesDefaultLighting = true
self.antialiasingMode = SCNAntialiasingMode.multisampling4X
self.allowsCameraControl = true
self.scene = scene
self.backgroundColor = UIColor.white
}
catch {
print("cannot find or open SCN file")
}
Any idea?
ios textures scenekit modelio
Do you have light?
– E.Coms
Nov 7 at 23:59
yes. it renders body part fine. but only floor has issue since it is transparent plane and shadow png texture has been mapped and it is rendered in black.
– yjpark
Nov 8 at 15:44
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
obj file has 2 objects - body and floor.
Floor is a simple clear transparent plane with just 4 vertices.
And I applied both PNG (with transparent area) and JPEG textures, but it all renders in black.
I also tried
transparent.contents = UIImage(named:"floor.png")
I don't know how I can render it properly.
I am using two approaches.
- Load obj file via model io then add to scene node.
- Load .scn file where the model'd been added beforehand.
But both didn't work out.
The following is the code that I am using now.
With Model I/O
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)
}
}
}
With .scn file
(In the preview of scn file, it was rendered properly, but not in the app)
let url = URL(fileURLWithPath: dir+"/model.scn")
do {
let scene = try SCNScene(url: url, options: nil)
scene.background.contents = UIColor.white
modelNode = scene.rootNode.childNodes[1]
//modelNode.childNodes[0].geometry?.materials[0].transparencyMode = SCNTransparencyMode.rgbZero
self.autoenablesDefaultLighting = true
self.antialiasingMode = SCNAntialiasingMode.multisampling4X
self.allowsCameraControl = true
self.scene = scene
self.backgroundColor = UIColor.white
}
catch {
print("cannot find or open SCN file")
}
Any idea?
ios textures scenekit modelio
obj file has 2 objects - body and floor.
Floor is a simple clear transparent plane with just 4 vertices.
And I applied both PNG (with transparent area) and JPEG textures, but it all renders in black.
I also tried
transparent.contents = UIImage(named:"floor.png")
I don't know how I can render it properly.
I am using two approaches.
- Load obj file via model io then add to scene node.
- Load .scn file where the model'd been added beforehand.
But both didn't work out.
The following is the code that I am using now.
With Model I/O
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)
}
}
}
With .scn file
(In the preview of scn file, it was rendered properly, but not in the app)
let url = URL(fileURLWithPath: dir+"/model.scn")
do {
let scene = try SCNScene(url: url, options: nil)
scene.background.contents = UIColor.white
modelNode = scene.rootNode.childNodes[1]
//modelNode.childNodes[0].geometry?.materials[0].transparencyMode = SCNTransparencyMode.rgbZero
self.autoenablesDefaultLighting = true
self.antialiasingMode = SCNAntialiasingMode.multisampling4X
self.allowsCameraControl = true
self.scene = scene
self.backgroundColor = UIColor.white
}
catch {
print("cannot find or open SCN file")
}
Any idea?
ios textures scenekit modelio
ios textures scenekit modelio
edited Nov 7 at 18:52
user6910411
31.9k76692
31.9k76692
asked Nov 7 at 16:30
yjpark
1
1
Do you have light?
– E.Coms
Nov 7 at 23:59
yes. it renders body part fine. but only floor has issue since it is transparent plane and shadow png texture has been mapped and it is rendered in black.
– yjpark
Nov 8 at 15:44
add a comment |
Do you have light?
– E.Coms
Nov 7 at 23:59
yes. it renders body part fine. but only floor has issue since it is transparent plane and shadow png texture has been mapped and it is rendered in black.
– yjpark
Nov 8 at 15:44
Do you have light?
– E.Coms
Nov 7 at 23:59
Do you have light?
– E.Coms
Nov 7 at 23:59
yes. it renders body part fine. but only floor has issue since it is transparent plane and shadow png texture has been mapped and it is rendered in black.
– yjpark
Nov 8 at 15:44
yes. it renders body part fine. but only floor has issue since it is transparent plane and shadow png texture has been mapped and it is rendered in black.
– yjpark
Nov 8 at 15:44
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53193749%2fios-transparent-area-with-texture-rendered-in-black-obj-scenekit-model-io%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you have light?
– E.Coms
Nov 7 at 23:59
yes. it renders body part fine. but only floor has issue since it is transparent plane and shadow png texture has been mapped and it is rendered in black.
– yjpark
Nov 8 at 15:44