My bad, I didn’t noticed you where talking about “minecraft lightmap style”…
Anyway, I’ve just finished reading all the stuff and i need to say that’s pretty interesting, and now i understand why i couldn’t figure out some stuff
Plenty of bugs still but I actually have basic light working. In a business application I can pump out functionality like a machine but in games it took me a solid week and a half to figure out a buggy version of lighting…lol.
I am still not including day/night cycles. @pspeed why is the shader the way to go for day/night lights? My understanding is that the shader code written is compiled by the Open GL framework and sent down to the GPU to run on the chip itself without having to travel so far. So it is able to change the look of the world without me having to rebuild the mesh. Is that correct?
It’s like a program that runs on the GPU. One transforms raw mesh data into something that can be turned into pixels. The other calculates the pixel values.
You should really really really do some googling on this topic as it’s too huge to cover properly here.
The snippets you posted really helped me out, thanks!
I needed to get it working with the “Lighting.j3md” Material and based on what you posted figured out how to combine both baked lighting and a directional light:
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", tex);
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
mat.setBoolean("UseVertexColor", true); // activates our custom colour lighting
The key was setting the UseVertexColor boolean flag to true, which activates the Color buffer. My next task is now to work out how to create two Color buffers, one for night, and the other for day, interpolating between them on the GPU. I guess I’ll need to fiddle around with the shader code to do that.