google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

SFA created with texture issue #37

Closed rramprasad closed 6 years ago

rramprasad commented 6 years ago

I have converted .obj file with .mtl and .jpg texture. It converts to sfa and sfb. But the texture is having some issues like below,what is missing in this?

created .sfa file:

{
   materials: [
      {
         name: "icon_03",
         parameters: [
            {
               baseColor: "icon_03",
            },
            {
               baseColorTint: [
                  0.80000000000000004,
                  0.80000000000000004,
                  0.80000000000000004,
                  1,
               ],
            },
            {
               //metallic: 1,
               metallic: 0,
            },
            {
               //roughness: 0.19611600000000001,
               roughness: 1,
            },
            {
               opacity: null,
            },
         ],
         source: "build/sceneform_sdk/default_materials/obj_material.sfm",
      },
   ],
   model: {
      attributes: [
         "Position",
         "TexCoord",
         "Orientation",
      ],
      file: "sampledata/models/icon_03.obj",
      name: "icon_03",
      scale: 0.05,
      suggested_collision: {
         center: {
            x: 0,
            y: 0,
            z: 0,
         },
         size: {
            x: 1,
            y: 1,
            z: 1,
         },
         type: "Box",
      },
   },
   samplers: [
      {
         file: "sampledata/models\\icon_03.jpg",
         name: "icon_03",
         pipeline_name: "icon_03.jpg",
      },
   ],
   version: "0.51:1",
}

icon_03.mtl

newmtl icon_03
map_Kd icon_03.jpg
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.000000 0.000000 0.000000
illum 2
Ns 50.000000
Tr 1.000000

Issue in texture:

device-2018-05-22-160916

Original texture:(.jpg file) icon_03

Android Studio 3.1.2 Build #AI-173.4720617, built on April 14, 2018 JRE: 1.8.0_152-release-1024-b02 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

rramprasad commented 6 years ago

Any idea about this issue?

AdrianAtGoogle commented 6 years ago

Hi @rramprasad thank you for submitting this issue. The lighting on the asset in your screenshot definitely doesn't look right. It looks like there are a few different issues:

rramprasad commented 6 years ago

@AdrianAtGoogle,please see comments below,

If you're concerned about shininess, this is happening because of the line Ns 50.000000 in your .mtl file. That is requesting a material with a very high phong exponent, which in our lighting model maps to a very low roughness. Try setting the 'roughness' parameter in your .sfa to 1.0 and rebuild.

Yes,Already my .sfa roughness parameter is 1.0. So the output is same as above screenshot.

It looks like the geometry with the icon texture isn't exported with normals. There is an issue in the 1.01 release where normal generation always makes a fully smoothed model, which is rarely what people want. This will be addressed in the next release; in the meantime you can work around by exporting explicit normals to your .obj file.

I think already by .obj contains normals. I have attached my .obj file(renamed .obj to .txt). Is it anything issue in this .obj file? icon_03.txt

AdrianAtGoogle commented 6 years ago

Hi @rramprasad, You're correct that the model already has normals - in fact it seems that is the problem. I saved your linked text file as an .obj, made the .mtl and the .jpg from the contents of the OP, and imported the model into blender 2.79 - the result has the same issues present in the sceneform asset.
Here is a screenshot: image

The normals in the asset do not seem to be correct; many of them are inward facing (causing the lighting seams across triangles). The normal issues need to be fixed in the source asset

claywilkinson commented 6 years ago

Sounds like this resolved - please reopen if not. Thanks!!