0

I'm now applying my recent work to some "real" game level and find an issue with the lighting. In this level I'm using a light source which should be like a "cube" (see picture). I'm currently using a point light for this (left image) centered on the "cube" light but of course the supporting pilar is not lit correctly because of its normals. In my previous model based on just vertex to light distance the pilar was "correctly" lit but the impact of the normals of the objects in the scene was not taken into account (except directional light). In this new lighting model I want to take these normals into account also for my pointlights used as "cube" lights. I can solve partly this by considering for each pointlight 4 decal postions (e.g. LPos.XZ +/- some value) but this makes 4x more calculations with important FPS slowdown just for having the pillar better lit and the result is not convincing at the end. I can think of designing a specific shader for the pilar but I prefer to avoid this. Has anyone already deal with that? Any idea welcome. (currently in forward shading mode).

enter image description here

philB
  • 129
  • 8
  • Have you considered baking a lightmap for it? – Mangata Apr 20 '22 at 12:52
  • It was a sort of lightmap in my previous version of the engine. All the faces impacted by the lights were detected at start and "duplicated in a specific mesh rendered as an extra pass. But lightmaps don't manage normals. This new shader version is also faster. – philB Apr 20 '22 at 16:01
  • I mean, since lightmaps are used, why does the extra computation reduce the FPS? Sorry I don't know much about rendering, When I work on a game engine(like unity),Normally I would handle static lighting by baking lightmaps offline(Using area lights for pillars). This is more standard practice. :-) – Mangata Apr 21 '22 at 05:55
  • It's not obvious on the image but the ground is bumped with normalmap. For the pointlight to impact the bump you need to calculate pixel to light distance to find the direction and dot with the bump texture normal. Then you compute the light color intensity. When you get the light from a lightmap you need also to calculate the projection uv coordinate. At the end for this case I think It's almost the same and I save a texture slot. I agree that if you don't need to bump and if the light is static a lighmap is ok. But there you can even include it in texture at level creation. – philB Apr 21 '22 at 07:19
  • may I say on my side I don't know about Unity. I'm coding everything the old way with C++ – philB Apr 21 '22 at 07:30
  • Sorry it seems beyond my ability to solve your problem. Considering that you are implementing some low-level functionality manually, Maybe the way modern game engines work will bring some inspiration. In unity we mark a light as "baked mode", and mark a mesh as "lightmap static", Baking is only done on these two lights and objects. In my imagination, You can use a lot of lights to just bake the pillars, This will not lower your FPS. and use real-time lighting calculations for the ground to use it's normal map. – Mangata Apr 21 '22 at 08:04
  • Hi Mangata, finally i have added my previous lighting just for the pilars. Maybe it could be time for me to start using more recent tools to do just the environment settings. I'm not sure to which point unity can drive me. At the end my goal is to have skinned crowd in the level (up to 32 by now) and some AI to manage them or some automatic behavior for the player. – philB Apr 22 '22 at 14:47

0 Answers0