Custom Mesh baked in lighting

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 :smiley:

Well sorry for that. Good luck.

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?

Here are some screenshots of where I am.

1 Like

Yes, setting one uniform is cheaper than rebuilding and resending a whole mesh every time the sun moves a little.

Ok. So is a shader like a mini call back function running on the GPU that gets called during the rendering pipeline?

The reason I am asking is because I have not read anything that explains it that way, but from what I have read, it seems to be true.

Just not sure.

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.

1 Like

I have done some reading but none that explained it in the way my mental model described it.

You seem to explain things to me in a very understandable way, so that’s why I asked.

Thank you!

By the way, you confirmed what I was thinking. No need to explain anything else.

Looking at a more simple shader like JME’s Unshaded would be educational most likely.

1 Like

Will do thank you.

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.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.