[SOLVED]Only one Point Light or Directional Light in cavas?

It seemed like when rendering an object, it will find closest Point Light to render, and ignore other point light.


1 Like

that doesn’t sound right, can you add a spatial at the light positions so we can better see what is going on.

thx! This is my sdk, showed the point light position.

that looks like it’s rendering correctly to me, I see blue light, I see yellow light, I see mixtures of both, can you explain in more detail the issue you are having?

(… make sure your materials are using the correct BlendMode, this may explain the symptoms you are describing)

I’m using the TestCanvas.java.
My app code is:

import com.jme3.app.SimpleApplication;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Sphere;

public class CavasApp extends SimpleApplication {
public static void main(String[] args) {
CavasApp cavasApp = new CavasApp();
cavasApp.start();
}

@Override
public void simpleInitApp() {
	Geometry ball = new Geometry("ball", new Sphere(20, 20, 1));
	Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
	ball.setMaterial(mat);
	rootNode.attachChild(ball);

	PointLight pl1 = new PointLight();
	pl1.setColor(ColorRGBA.Yellow);
	pl1.setPosition(new Vector3f(0, 1, 1));
	rootNode.addLight(pl1);

	PointLight pl2 = new PointLight();
	pl2.setColor(ColorRGBA.Blue);
	pl2.setPosition(new Vector3f(1, 0, 1));
	rootNode.addLight(pl2);
}

}


cannot see blue in cavas.


can see blue in simpleApplication.

oooh, yeah I see what you are saying

I would recommend using the awtPanel, canvas has always been dodgy.
But still that’s a weird issue…

thx! Do you know why Jme sdk display right?
Is sdk use cavas?

You can change that setting in the SDK, but the default is the awt panel afaik.

Can confirm that when I was using Swing Canvas everyone else on the team told me I should be using AWTPanels. :slight_smile:

Can also confirm that this is not the only issue you will find with Swing Canvas as for some reason it sometimes sorts the guidNode backwards, for example.

After I test, jme3.0 is no problem on this issue.
jme 3.1 has this problem.
I guess it’s beacuse lwjgl version.

I get reason why jme3.1 has only one light in cavas. It’s because light mode.
Use these two row code to fix that.

    renderManager.setPreferredLightMode(LightMode.SinglePass);
    renderManager.setSinglePassLightBatchSize(16);

The number is max light. Thank you all!

mhhhh
still weird, the batch size set the number of lights rendered at once. But all lights should be rendered, even if the renderer has to do several passes. That’s still an issue IMO.