1
\$\begingroup\$

My model must support transfer textures but I can't do this using mesh + modelBuilder.part

Opacity is tested correctly on only half of the model.

BlendingAttribute blendingAttribute = new BlendingAttribute();
        blendingAttribute.opacity = 1.0f;
        
        modelBuilder = new ModelBuilder();
        modelBuilder.begin(); 
        modelBuilder.part("minecraft:loading_model", mesh, 4, new Material(TextureAttribute.createDiffuse(atlas), blendingAttribute));
        modelInstance = new ModelInstance(modelBuilder.end());
\$\endgroup\$
7
  • 1
    \$\begingroup\$ It looks like you should show us the relevant code to reproduce this problem. \$\endgroup\$ Commented Jun 22, 2020 at 20:44
  • \$\begingroup\$ Really .. sorry I went down \$\endgroup\$ Commented Jun 22, 2020 at 21:42
  • \$\begingroup\$ Looks like you're using alpha blending, without disabling z writes. You more likely want to use alpha testing, so that you abort the transparent fragments before they write to the depth buffer and block the next quad from drawing there. \$\endgroup\$ Commented Jun 22, 2020 at 21:45
  • \$\begingroup\$ Yes, the minecraft oak tree should be composed of two planes with transparent pixels \$\endgroup\$ Commented Jun 22, 2020 at 21:49
  • \$\begingroup\$ I found the solution in a badlogic forum. modelInstance.materials.get(0).set(FloatAttribute.createAlphaTest(0.95f)); \$\endgroup\$ Commented Jun 23, 2020 at 2:42

1 Answer 1

1
\$\begingroup\$

I found the solution in a badlogic forum.

This:

modelBuilder.part("minecraft:loading_model", mesh, 4, new Material(TextureAttribute.createDiffuse(atlas), blendingAttribute, FloatAttribute.createAlphaTest(0.95f)));

Or this:

modelInstance.materials.get(0).set(FloatAttribute.createAlphaTest(0.95f));

enter image description here

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.