More than 8 Lights on 1 object

Howdy everybody.



If I were to have many objects, say 300-500 characters, "standing" on top of another object, say a 64x64 TerrainBlock stretched to the scale 10,1,10 and wanted to have each of those characters have a PointLight on them, how would I accomplish this?



Think about a StarCraft Terran base. Now, imagine each character having it's own little light source. Cool, right? Right. They wouldn't need to be able to generate shadows, I don't think, but I do want to have the areas around characters lit.



Unfortunately, the TestManyLights.java demo doesn't accomplish what I'm looking for. That basically ignores lights that are far away, if I am understanding correctly.



Here's a simple test which illuminates :smiley: the problem.



What are possible workarounds to having the same object lit by so many lights?



package com.trussell.genesis;

import com.jme.app.SimpleGame;
import com.jme.light.PointLight;
import com.jme.light.SimpleLightNode;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.shape.Sphere;
import com.jmex.terrain.TerrainBlock;

public class TestLights extends SimpleGame
{
   public static void main(String[] args) {
      TestLights tl = new TestLights();
      tl.setConfigShowMode(ConfigShowMode.AlwaysShow);
      tl.start();
   }
   
   @Override
   protected void simpleInitGame() {
      makeGround();
      makeLights();
   }
   
   @Override
   protected void simpleUpdate() {
      rootNode.sortLights();
   }
   
   private void makeGround() {
      TerrainBlock tb = new TerrainBlock("terrain", 16,
            new Vector3f(10,1,10), new float[16*16], new Vector3f(0,0,0));
      rootNode.attachChild(tb);
   }
   
   private void makeLights() {
      lightState.detachAll();
      for(int i=0; i<160; i+=10) {
         for(int j=0; j<160; j+=10) {
            PointLight pl = new PointLight();
            pl.setEnabled(true);
            pl.setAttenuate(true);
            pl.setLinear(.1f);
            pl.setQuadratic(.4f);
            pl.setConstant(.5f);
            
            pl.setDiffuse(ColorRGBA.randomColor());
            
            lightState.attach(pl);
            
            Sphere s = new Sphere("light"+i, 10, 10, 1);
            SimpleLightNode ln = new SimpleLightNode("light"+i+"node", pl);
            ln.attachChild(s);
            rootNode.attachChild(ln);
            ln.setLocalTranslation(new Vector3f(i, 1, j));
         }
      }
   }
   
}

Why use real lights? For statics the normal approach are lightmaps, so logially for many lights the idea would be a projected texture, , in the starcraft example you jsut project a spotlight texture from somewhere inside the marine to the ground (while ignoring the marine of course)

Just to quickly clarify, the units aren't statics at all. They are very much dynamic.



What texture could I use? Are you suggesting just a circular white texture with an alpha value < 100 (like 50)? Basically projecting something that would "lighten" the area around the character without actually using a light?

I think thats what hes suggesting.

That Texture gets loaded to a texture layer in the floor (static) texture once and gets projected multiple times by the units.

This, of course, comes with the cost of 1 texture unit on the ground. This means I am able to use fewer textures than I might want to when I multi-texture it.



But, it's not to be written off. This seems like a very plausible solution. Looking at TestProjectedTexture, I'm unsure of how to go about projecting that one texture from multiple sources, though.

Deferred Lighting seems to be what companies are moving toward. Can handle many lights, and deal with trancparancies. Its what farcry 3 engine will be using, now theyve moved away from the fully deffered pipeline they used in farcry 2 engine.



Diary of a Graphics Programmer: Light Pre-Pass Renderer

Real-Time Rendering ยท Deferred lighting approaches