lighting problems for batch geometry
I created a scene using the TreeLoader3D, which consists of many different tree entities. When I add these entities to the scene without pagedGeometry everything looks fine. When I use pagedGeometry, all batch entities appear unlit (when geometry is close to camera), the imposters/billboards look correct as I move the camera away from the geometry). The scene has a couple of directional lights, and all entities have a simple material file with a single texture. BTW, if I change the ambient attribute in the material file from (0 0 0 1) to (1 1 1 1), I do see the material, though I would like it to appear the same as when the entities are added to the scene without pagedGeometry? Has anyone seen similar effects? Any ideas how to fix this?
Thanks in advance!
BatchPage automatically applies a auto-generated vertex shader that fades vertexes in/out between LODs (this is necessary for LOD transitions), but unfortunately due to the inherent inability to mix shaders, this means this auto-generated fade shader overrides the default lighting behavior.
To use multiple lights or other features beyond very basic lighting, you'll have to add or modify the vertex shader used in BatchPage as necessary. One way is to give your trees a custom vertex shader that supports PagedGeometry's fade parameters. Another way is to directly modify the shader generator embedded in BatchPage.cpp to generate the lighting behavior you need.
I wish there was an easier way to do this, but unfortunately there's no "modular" way of mixing plain shaders, at least Ogre doesn't have any system or strategy to do so (but neither does any other general-purpose engine that I know of).
Actually, this also happens when I use a single directional light in the scene.
Does BatchPage create the vertex shader only for fading? So if we are willing to give up on the fading effect, we could write our own BatchPage which simply uses the existing material instead of the shader, right?
Does BatchPage create the vertex shader only for fading?
It also uses it for coloring trees, which is done in a different way than fixed-function would permit (looks better when applying lightmaps to forests).
So if we are willing to give up on the fading effect, we could write our own BatchPage which simply uses the existing material instead of the shader, right?
Yes, that would definitely be possible, although obviously you'd be giving up fade transitions like you say.