Hi again, different topic now.
I have a spatial that I create like this:
private Spatial createShip(int ship) {
Quad quad = new Quad(CoreViewConstants.SHIPSIZE, CoreViewConstants.SHIPSIZE);
//<-- Move into the material?
float halfSize = CoreViewConstants.SHIPSIZE * 0.5f;
quad.setBuffer(VertexBuffer.Type.Position, 3, this.getArray(halfSize));
//-->
quad.updateBound();
Geometry geom = new Geometry("Ship", quad);
Material mat = assets.loadMaterial("Materials/ShipMaterialLight.j3m");
//Material mat = assets.loadMaterial("Materials/ShipMaterialUnshaded.j3m");
geom.setMaterial(mat);
setShipMaterialVariables(geom, ship);
//mat.setInt("numTilesOffsetY", ship);
geom.setQueueBucket(RenderQueue.Bucket.Transparent);
PointLight myLight = new PointLight();
myLight.setColor(ColorRGBA.White);
myLight.setRadius(20);
rootNode.addLight(myLight);
ShipLightControl lightControl = new ShipLightControl(myLight);
geom.addControl(lightControl);
//Test:
//AmbientLight al = new AmbientLight();
//al.setColor(ColorRGBA.White.mult(1.3f));
//rootNode.addLight(al);
//<--
return geom;
}
The ShipLightControl is this:
public class ShipLightControl extends LightControl {
PointLight pointLight;
Vector3f pos;
public ShipLightControl(PointLight pointLight) {
super(pointLight);
this.pointLight = pointLight;
}
@Override
public void update(float tpf) {
//super.update(tpf);
if (this.enabled && this.getSpatial() != null && pointLight != null) {
pos = this.getSpatial().getLocalTranslation();
pointLight.setPosition(pos.add(0, 0, 2));
}
}
}
The material of the ship is this:
Material ShipMaterialLight : MatDefs/StaticSprite/StaticSpriteLightShader.j3md {
MaterialParameters {
//AniTexMap : Flip Textures/Subspace/ships.bmp
numTilesX : 10
numTilesY : 32
numTilesOffsetX : 0
numTilesOffsetY : 3
DiffuseMap : Flip Textures/Subspace/ships.bmp
UseMaterialColors : true
Specular : 1.0 1.0 1.0 1.0
Diffuse : 1.0 1.0 1.0 1.0
Shininess : 1.0
}
AdditionalRenderState {
Blend Alpha
Wireframe Off
}
}
I try to position the light above the ship-quad, so that the ship is illuminated by the light. It works to begin with:
But when I rotate the quad, the light fades:
Anyone have any pointers or places I can look to fix this ?
In the Docs, it says that there are these:
g_LightPosition: the position of the light
use for PointLight: x,y,z contain the world position of the light, the w component contains 1/lightRadius
But doesnt mention anything about direction for a pointlight. My shader is based on the lighting.j3md
- I’m trying to see if lighting.j3md has been updated since I looked at it.