Please note, you wanted me to create TestCase for you. dont do this next time please
Just provide it all.
Here is TestCase i made based on your Kotlin code:
package test;
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.shadow.DirectionalLightShadowRenderer;
public class Test3 extends SimpleApplication {
private final float mFrustumSize = 490f;
private final float mCamXRot = 1.5f;
private final float mCamYRot = 0f;
private final float mCamZRot = -0.5f;
private float mAspect;
public static void main(String... argv) {
Test3 app = new Test3();
app.start();
}
@Override
public void simpleInitApp() {
setCamera();
updateCamRotation(cam);
updateFrustum(cam);
DirectionalLight sun = new DirectionalLight(new Vector3f(1f, -0.2f, -1f).normalizeLocal());
rootNode.addLight(sun);
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, 1024, 3);
dlsr.setLight(sun);
viewPort.addProcessor(dlsr);
createBox(new Vector3f(100, 0, 100));
createBox(new Vector3f(200, 0, 200));
createBox(new Vector3f(-100, 0, -100));
createBox(new Vector3f(-200, 0, -200));
createBox(new Vector3f(-500, 0, 0));
inputManager.setCursorVisible(true);
flyCam.setZoomSpeed(0);
flyCam.setMoveSpeed(0.0f);
flyCam.setEnabled(false);
flyCam.setRotationSpeed(0);
}
private void createBox(Vector3f loc) {
Box b = new Box(100, 100, 100); // create cube shape
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Diffuse", ColorRGBA.Gray);
mat.setColor("Specular", ColorRGBA.White);
mat.setFloat("Shininess", 64f); // [0,128]
geom.setMaterial(mat); // set the cube's material
rootNode.attachChild(geom); // make the cube appear in the scene
geom.setLocalTranslation(loc);
}
private void setCamera() {
cam.setParallelProjection(true);
mAspect = cam.getWidth() / cam.getHeight();
cam.setLocation(Vector3f.ZERO);
updateFrustum(cam);
updateCamRotation(cam);
cam.update();
}
private void updateCamRotation(Camera cam) {
System.out.println("Setting Rotation X: $mCamXRot, Y: $mCamYRot, Z: $mCamZRot"); //NON-NLS
cam.setRotation(new Quaternion(new float[]{mCamXRot * FastMath.HALF_PI, mCamYRot * FastMath.HALF_PI, mCamZRot * FastMath.HALF_PI}));
}
private void updateFrustum(Camera cam) {
System.out.println("Setting Frustum Size to: $mFrustumSize"); //NON-NLS
cam.setFrustum(-1000F, 1000F, -mAspect * mFrustumSize, mAspect * mFrustumSize, mFrustumSize, -mFrustumSize);
}
}
I were able to replicate some “light difference” you talk about
image:
When using different Camera location like:
cam.setLocation(new Vector3f(1000,1000,1000)); // extending frustrum far too
this box is not more “specular lit”
The “more lit area” what we see here is Specular Since:
mat.setColor("Specular", ColorRGBA.White);
when this color is black, will not see this area anymore. So this is specular.
It is how it works, but im not sure if its intended for “parallel projection” view.
As i know specular is added by Shader in:
Lighting.frag l:207 and it is BlinnPhongLighting.glsllib#L31
Temporary solution for you @superjugy if you want have exactly same visual,
is to make Specular Color Black. (you can also setup Shininess param so it will not focus on small area)
Im also not sure if your camera rotation or frustrum params might cause exactly this specular appearance.
Anyway: How do you expect specular to work in parallel projection? Because im not sure myself.
You can ofc. use specular and make each “ninja” render in own viewport, so each of them will have own specular. But i dont think specular should affect them a way you want it, without split render into separate render of this characters.
Since im not sure if this works as expected in Parallel Projection, i cant say if its correct or not.
Need to wait for someone opinion.