Hello, having all my game mechanics in place, i started experimenting with lighting. What i need to do is increase overall brightness of each spatial based on some external factors.
One way i thought of is attaching separate ambient light to every spatial and adjusting it when needed. However, this doesnt seem like a good solution since it requires a lot of code and probably would decimate the framerate (since there can be quite a bit of these including walls, pickable items,enemies etc). Is there any solution to this problem that would not affect performance as much?
You mean you just want the spatial to glow or something?
You may have to show code and describe what you mean through pictures or something. I can interpret your question about 47 different ways.
I want each object to be evenly lit (so it looks flat just as if it was lit with ambient light) on each side, but i also want to be able to adjust the brightness level of each individual spatial like so:
as you can see the gas mask closest to the camera is the brightest, and the further they are the darker they get (but each face of the model is affected evenly)
If you are using Lighting.j3md, then you can set the Diffuse and Ambient material params as a color for each spatial to scale the final lighting without needing a new light for each spatial.
But more information would still be helpful, since I’m only guessing you’re using Lighting.3md
Yeah just tested that out, seems to work exactly as i wanted. Thanks!
Actually the solution was .mult() value which i had written just above but commented out.
For future visitors:
Material mat_default = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat_default.setBoolean("UseMaterialColors",true);
mat_default.setColor("Ambient", ColorRGBA.White.mult(x)); // x is how bright you want the material to be
mat_default.setTexture("DiffuseMap", assetManager.loadTexture(texturePath));
node.setMaterial(mat_default);
To me this means you don’t want lighting but you want unshaded.
Do you also have an ambient light in your scene?
Yes, i do have ambient light, everything works fine, the problem is solved.
had to add
mult(x)
in
mat_default.setColor("Ambient", ColorRGBA.White);
Sorry for asking an imprecise question
But if you are making all of your objects have “super white” ambient value then it really means a) you want a brighter ambient scene light, or b) you are using the wrong material.
Cranking up ambient super high will wipe out everything regular lighting is doing. Normals, normal maps, bump maps, etc… all essentially wiped away.
…in which case you might as well use the Unshaded material instead. The same one the “blue cube” examples use.
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
The reason i needed this is because i wanted to get the material from geometry, and set its “brightness” depending on the distance from the light the player has, which gives a unique effect and eliminates the problem of uncanny “smooth” lighting with voxel-style graphics. i.e if the item that lies on the floor is farther away than the radius of player spotlight, it will be assigned some minimal brightness (so the objects far away arent pitch black), and as it gets closer (measured in “steps” i.e 1/10th of light radius) it gets brighter up to some value.