Hello, i have a 3D spehere in my GUI node. It shoud have diffuse normal and specular textures, but i noticed that specularity does not work for some reason. After a lot of playing and tweaking i noticed that the specular effect appears at wrong position. It should appear in the direction of the light source, shouldn’t it?
The following is a very simple example demonstrating the issue:
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Sphere;
import com.jme3.util.TangentBinormalGenerator;
public class Test extends SimpleApplication {
public static void main(final String[] args) {
final Test app = new Test();
app.start();
}
@Override
public void simpleInitApp() {
final DirectionalLight directionalLight = new DirectionalLight();
directionalLight.setDirection(new Vector3f(0f, -1f, -1f));
directionalLight.setColor(ColorRGBA.White);
guiNode.addLight(directionalLight);
final Sphere planetMesh = new Sphere(128, 128, 1f);
final Geometry planetGeometry = new Geometry("Planet", planetMesh);
final float size = Math.min(settings.getWidth(), settings.getHeight());
planetGeometry.setLocalScale(size * .3f);
TangentBinormalGenerator.generate(planetGeometry);
final Material planetMaterial = new Material(assetManager,
"Common/MatDefs/Light/Lighting.j3md");
planetMaterial.setBoolean("UseMaterialColors", true);
planetMaterial.setColor("Diffuse", ColorRGBA.White);
planetMaterial.setColor("Specular", ColorRGBA.Red.mult(20));
planetMaterial.setFloat("Shininess", 128f);
planetGeometry.setMaterial(planetMaterial);
final Node planetNode = new Node();
planetNode.setLocalTranslation(settings.getWidth() / 2, settings.getHeight() / 2, 0);
planetNode.attachChild(planetGeometry);
guiNode.attachChild(planetNode);
}
}
I would expect the red shining at the upper-middle part of the sphere.
Am i right about this, or am i doing something improperly?
(there are reasons why i’m attachign the sphere to the GUI node)
Thanks in advance.