Hi!
I'm more or less done with draft version of PBR unit shader.
You can find sources here:
https://github.com/lhog/Zero-K/tree/pbrCUS_v1
And see changes against vanilla ZK here:
https://github.com/lhog/Zero-K/compare/ ... :pbrCUS_v1
Generally the shader can be used in any spring game/mod. It's essential though that the game has some implementation of Custom Unit Shaders (CUS), that looks into the "Materials" directory or something like that.
What you need for integration:
1 ) Model. I only played with Collada/DAE models, others might work, but I've never tested that.
2 ) Model description file named <model.dae>.lua. My implementation uses same file as mentioned here:
https://springrts.com/wiki/Assimp except it extends it with "pbr" section. This section defines PBR textures and parameters to be used to render this model. See
https://github.com/lhog/Zero-K/blob/pbr ... ua#L10-L78 it's very well commented file.
3 ) PBR textures. These go into "unittextures" dir and should be referenced and described in <model.dae>.lua file. Note that if you use DDS, it might be a good idea to generate mip maps. It's especially important for normal map file.
4 ) brdflutTex.png. Don't bother what it is, just put it into "unittextures" dir from here
https://github.com/lhog/Zero-K/blob/pbr ... lutTex.png
5 ) Shader definition file.
https://github.com/lhog/Zero-K/blob/pbr ... rs/pbr.lua Put it in the same dir as in repository
6 ) Material parser file.
https://github.com/lhog/Zero-K/blob/pbr ... 10_pbr.lua Put it in the same dir as in repository
7 ) If you want your model to recieve the custom image based lighting (IBL). Define these two textures:
https://github.com/lhog/Zero-K/blob/pbr ... ua#L74-L76 If SPECULARMAP and/or IRRADIANCEMAP are existing files in "unittextures" dir then renderer expects them to be in equirectangular projection and in RGBE format. If SPECULARMAP and/or IRRADIANCEMAP are not defined, renderer uses standard reflection cubemap for both.
8 ) Some parameters (like final gamma correction or tonemapping or environment maps) are possible to define either in model file or in map file. Although latter exists in the code, I've never tested it so far. Should work, but you will never know until you test.
Ping me if I missed something or some point needs better description.