google-ar / sceneform-android-sdk

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

Feauture request: Add support for opacity map in .fbx files #704

Open Consti10 opened 5 years ago

Consti10 commented 5 years ago

After digging trough the default material source code I am not sure if opacity maps should even work with .fbx files (or general).

1. Reason why opacity maps should be supported: Modelling package 3DsMax needs opacity maps in standard renderer (no alpha channel supported)

2. How to use opacity maps with sceneform at the time -requires workaround / steps performed by artists Either follow workaround b) as described here #696 Or do it manually: a) Add opacity map via 'injections' as described in #696 a) b) Then create your own material definition with support for opacity map. Example: (line 137 in fbx_material.sfm) `{ name: "opacity", description: "Workaround for opacity map", options: [ { default: null, valid_if: propUseOpacityMap != 1.0, //blending: "opaque", fragment: "" }, { default: sfm.sourceTexture("Opacity"), valid_if: sfm.hasSourceTexture("Opacity"), requires: ["uv0"], fragment: float myOpacityValue = texture(materialParams_opacity, getUV0()).r; material.baseColor = material.baseColor * myOpacityValue;
      }
    ]
  }`

3. What I would like to see change in Sceneform: a) Modify the Sceneform importer to include support for opacity map textures b) Add the lines default: sfm.sourceTexture("Opacity"), valid_if: sfm.hasSourceTexture("Opacity"), requires: ["uv0"], fragment: ||| float myOpacityValue = texture(materialParams_opacity, getUV0()).r; material.baseColor = material.baseColor * myOpacityValue; ||| to the default .fbx material ( perhaps with a nicer layout, e.g. values opacity & opacityMap for sampled texture (like baseColor and baseColorMap)

nvasilescu commented 4 years ago

your fix doesn't seem to work anymore. I force blending to transparent in a custom material .sfm and a png with transparency that is used as a texture doesn't have any transparency.