I gived a try to this and had tons of troubles. I forked it and uploaded my attempt here
The main trouble is that the 'vecLight' vector has completely different values for blocks and entities. 'vecLight' is the only reference to PVR and overall ambient value so its usage is a must in order to get 'camera.ambient' implemented, but it happens that it has very strange values on blocks. After hundreds of tries and samples I arrived to undertand that blocks receive a 'vecLight' vector as follows:
amb_factor = camera.ambient + ent.ambient + ...;
amb_average = (ambient.r + ambient.g + ambient.b) / 3;
vecLight.r = (ambient.r + amb_factor + 128 - amb_average) / 255;
vecLight.g = so on...
Pretty weird, isn't it? The only solution I can think on is to compute the inverse operation in order to get the 'amb_factor' value and aplly it in the lightmap. Works but wtf?
Once I solved
this issue I tried to equalize the 'vecLight' passed to entities so it results in a similar colors of blocks but I have been unable.
It happens that terrains always receive 'vecLight' with the ambient value only, as far as I tested.
I also realized that sky blocks are rendered with 'mtl_sprite' material instead of 'mtl_sky'. I have been unable to make a samplerCUBE work over block sky textures so I could not overwrite the material.
At the end it works pretty well but far from the engines render output. Maybe someone want to give a try...