Actually this way works to, which is funny, since I am just creating a new Node called stageNode, and just pick every element out from the scene and add it to the stageNode, Its like doing double the work.
Shouldn’t it just be enough loading that scene?
I don’t understand your problem correctly, but if you have the following Nodes:
A => B => C
You load something, attach it as C to B, then only the children would be lit.
If you add it to A, everything is lit.
This is like here creating B and adding C etc.
If you only load the scene, then you have to add it to the rootNode, but then you have to see where the light probe is, it has to be in “stageNode” (so it should work).
We need the exact node/light hiearchies to see what is going wrong.
Its like you got a Car, but it have wheels objects and chaisis object, etc objects and all of this is under one Car Node(parent) that is “container” for all of this objects. if you add light to Car Node, everything will be affected by light, if you add only to some sub-node, for example wheel, then only wheel will be affected by light. (lightprobe also work same way)
Also some general info: Spatial can be anything, Geometry, Node, or even something else.
While only Node is “container” that you want use. In java you trully can just cast and see if(spatial instanceof Geometry) etc. so you know what it is.
also not sure if this will help you somehow, but there is video:
Generally Light Probe need Envmap to generate “map”. Nothing special, but it take some time to generate, so usually people “pre-generate” them in SDK or via code and save as j3o file.
Node a = loadModel("somescenewithlights");
Node b = new Node("copyNode");
copyAllIncludingLights(a,b);
// so a and b are identical having the same children and lights
//rootNode.AttachChild(a); // ambient light works and lightprobe not showing
//rootNode.AttachChild(b); // ambient light works and lightprobe works
So just by sheer observation that they don’t do the same,
which I don’t understand since they hold the same
things.
hmm, i dont really understand what you mean, but i think i will show you example i see myself, so you might understand it better:
//Models
Spatial PBRModel = loadModel("some PBR model"); //Spatial - it means it can be Geometry or Node, whatever - if this is all Scene, it will be Node.
Spatial NonPBRModel = loadModel("some NoN-PBR model"); //same it will be spatial so can be anything
/////////////////////////////////////////////////////////
// Some simple Scene graph structure
Node generalLitNode = new Node("generalLitNode");
Node pbrObjectsNode = new Node("PBR Node")
generalLitNode.attachChild(pbrObjectsNode); // we make pbrNode to be inside generalLitNode
generalLitNode .addLight(ambientLight);
generalLitNode .addLight(directionalLight);
generalLitNode.attachChild(NonPBRModel); // general(main) node that have lights here.
pbrObjectsNode.attachChild(PBRModel); // we have pbrNode where for example you will want all PBR objects. this PBR node is also in generalLitNode that have lights. But it also have LightProbe.
lightProbe = LightProbeFactory.makeProbe(environmentCamera, generalLitNode, new JobProgressAdapter<LightProbe>() {
....... (there is more code to generate it)
pbrObjectsNode.addLight(lightProbe);
So in this example you have
generalLitNode(general lights) → pbrObjectsNode(+light probe) + NonPBRModel.
Where in pbrObjectsNode → PBRModel
NonPBRModel is only in generalLitNode so it will be affected by general lights, even if it would be PBR Model, it will not be affected by LightProbe, because its not in this Node.
PBRModel is in pbrObjectsNode so it is affected by both generalLitNode(that have general lights) and pbrObjectsNode(that have lightProbe with generated envMap)
Also please focus on some sample i provided:
lightProbe = LightProbeFactory.makeProbe(environmentCamera, generalLitNode, new JobProgressAdapter<LightProbe>() {
....... (there is more code to generate it)
pbrObjectsNode.addLight(lightProbe);
What i mean here is that it generate probe envmap based on generalLitNode (that can be non-pbr scene, anything here) while lightProbe is put only to pbrObjectsNode to affect only PBR Models you put there.
You can create ANY sceneGraph you want, i just provided you some example to make you understand how it work
I’m doing as guys says attaching to the rootNode or parentNode higher in the hiearchy, as this is the right way. I was just fooling around, and try to copy some node to see difference in behaviors, that’s all. Many thanks for the help.
Just lights like directionalLight or AmbientLight IMO should not be in “this scenes”. but in some rootNode or some lightNode “higher in the hiearchy” like you said
LightProbe, SpotLight, AreaLight etc. can be in “this scenes” IMO.
Why? because if you will have DL Light in “this scenes”, you might have situation that this light will be “doubled” for example when scene will have DLLight and “parentNode higher in the hiearchy” will also have one. (but it also depends, there might be situations where you would want 2 Directional Lights). but it depends on game too. if you will have Scenes where you will “dont want DL Light”(or want different colors/intensity each scene), then this way(having DL light in scenes) is proper too.