[SOLVED] How to properly use reflect.j3md?

I’m looking to create a material that just uses a sphere map and “reflects” that. It seems like reflect.j3md is what I should be using, but let me know if I should be using something different.

I’m trying to replicate this look (the texture “warps” as you move around the object):
Annotation 2021-03-10 143057
The texture for that looks like:

Here’s what I’ve tried:

Material reflectiveMaterial = new Material(context.getAssetManager(), "Common/MatDefs/Misc/reflect.j3md");
reflectiveMaterial.setTexture("CubeMap", context.getAssetManager().loadTexture("Assets/HornSkin.bmp"));

The material is just solid black, even with a directional light (I’ve only applied it to the body of the sax here):

I can obviously get it to work with Unshaded.j3md, but this is not desired effect:

I’m assuming I’m just applying the material incorrectly (since the documentation page seems to describe it in a way that seems applicable to my situation).

So what am I missing or doing wrong?

Are you going for that cartoon style?

Else you may want to look at PBR where you might not need much of a texture at all and just set the material parameters right for shiny metal.

Yep, not going for photorealism.

There is a TestEnvironmentMapping class in the jme3-examples which sound like what you are after. I’m not in a position to run it and verify.

Thank you for that, I figured it out!

It was simple as increasing the FresnelParams. reflect.j3md must have been the wrong material.

material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
material.setVector3("FresnelParams", new Vector3f(0.1f, 0.9f, 0.1f));
material.setBoolean("EnvMapAsSphereMap", true); // My texture is a sphere map
material.setTexture("EnvMap", texture);

Now I need to figure out how to only apply this to part of the mesh, since the mouthpiece should be solid black…

1 Like

Split the mesh into multiple geometries under the same node.

…no other good way, really.

1 Like

Any way to configure this in .mtl files instead of splitting the mesh? The meshes are already .obj.

If the ‘objects’ inside the .obj have different materials then they will already be different Geometry under a single Node.

…no other way, really.

Got it, thanks.

1 Like