viromedia / virocore

ViroCore cross-platform AR/VR renderer
MIT License
370 stars 108 forks source link

How to use a transparent glass object? #350

Open knightcube opened 3 years ago

knightcube commented 3 years ago

Environment

Please provide the following information about your environment:

  1. OS: Windows
  2. Version: ViroCore version : v1.17.0
  3. Device(s): What device(s) are you are seeing the issue on (i.e. Samsung Note 8, Pixel 2 XL, etc) - Nokia 6.2

Description

I am having trouble making a 3D model of a glass transparent. The obj is getting placed but it's not transparent. How do I do that?

WhatsApp Image 2021-03-21 at 17 50 54

Here is the code that I am using to add the materials to the object👇 Am I missing something?

object3D.loadModel(mViroView.getViroContext(), Uri.parse("file:///android_asset/wine-glass.obj"), Object3D.Type.OBJ, new AsyncObject3DListener() {
            @Override
            public void onObject3DLoaded(final Object3D object, final Object3D.Type type) {
                final List<Material> materials = object3D.getMaterials();
                for (Material material : materials) {

                    material.setShadowMode(Material.ShadowMode.TRANSPARENT);
                    material.setLightingModel(Material.LightingModel.PHYSICALLY_BASED);
                    material.setTransparencyMode(Material.TransparencyMode.A_ONE);
                }
                object3D.getGeometry().setMaterials(materials);
            }

            @Override
            public void onObject3DFailed(String s) {
                Toast.makeText(ViroActivityHelloAR2.this, "Error Loading Object", Toast.LENGTH_SHORT).show();
            }
        });

Reproducible Demo

Let us know how to reproduce the issue. Include a code sample, screen capture, video recording. The more information you provide, the better we can support you.

knightcube commented 3 years ago

I bought an fbx model and converted it to vrx. It looks like a glass of blood rather than wine. Here is the link to the model - https://sketchfab.com/3d-models/wine-glass-07ad17d4ac40464ca276715dc12d8efa

I have access to the materials and textures but how do I apply or tune them to match the look of wine rather than blood. Screenshot_20210330-182533