• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Torch light disappearing

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Can someone explain to me why when I have a custom model (no mesh, just omni light) in my map, all other light sources stop working?
The fixed function shader pipeline used by Warcraft III only supports a maximum of 8 different light sources per vertex patch. Since it is possible to have more than 8 lights in a scene Warcraft III uses a spatial light selection model that tries to select the 8 most appropriate lights to render a vertex patch. This is good enough for accurate lighting in most cases, such as a few torches with huge distances between them. However if there are a lot of lights present in close proximity then it is possible that less significant lights get selected or that not enough lights can be selected for reasonable illumination.

8 lights might seem a lot but one must remember that 1 light is already used by the global environment model. Additionally portraits might use lights, which seem to have a spatial positioning of 0,0 (selecting Crypt Lord unit will cause the middle of the map to get brighter!).

Any custom lights have to be kept small so that the spatial light selection algorithm can function reasonably well. If they are made too big, eg global, then the algorithm might select them from far away when there are much closer lights that are more meaningful. In the worst case it is possible that the algorithm will even discard the global environment model light in favour of other lights, resulting in there being no base level of brightness for the vertex patch (likely what is happening to you).

Coping with more lights per vertex patch would have required additional passes through the pipeline (each pass for 8 lights so 24 lights would be 3 passes) with the results being blended together. This causes scene complexity to be dependent on the product of number of lights and number of vertex patches. This square like scaling would mean that scenes with a lot of lights could potentially perform very badly despite having only average patch complexity, a situation where one can go from high FPS to low FPS just by moving the camera around. To prevent such complexity scaling from occurring Blizzard decided to limit each patch to a single lighting pass so render time was only dependent on the number of vertex patches in the scene.

Technically the 8 light limit applies to processing fragments, however the lights used have to be specified per vertex patch job and so are constant for all fragments from that vertex patch.

If you want to use light as a gameplay element I recommend using StarCraft II rather than Warcraft III. StarCraft II has a much more advanced lighting system which can deal with a near infinite number of lights in a scene as well as have spotlights that cast shadows. This is the difference around 10 years of technology and using programmable shaders makes.
 
Status
Not open for further replies.
Top