How many lamps?

Hello all, I know this question has been asked alot before but I was wondering how many lamps can bge handle as of the current version? Is it still eight or can it handle more? Also, can turning a lamp value down to 0 help improve the performance is is stilll counted when the game is rendered? Thanks in advanced. :slight_smile:

lamps use resources when the value is zero,

as far as to how many lamps , that is specific to your rig,

Wrectified uses 30 lamps, over and over again using a dynamic lighting manager to move the lamp to where it is needed.

I guess you can test out the performance yourself, but to ensure it runs well on most computers it is probably recommended to keep the light count down to around 8.

You can also use LoD for a light, by parenting it to an empty and then spawning it in when the player gets close and removing it when the move away.

yes, but lights on the unused layer still use resources.

having ‘Light hooks’ list generated on frame 0, and then using pythons ‘sorted’ feature using the current distance is the best way to go. (from every test I have done)

a automated native code version of this would be very cool.

only for ‘environmental’ lamps,

FX lamps I add using .addObject()

this assumes that all the lamps to be used for the light manager are parented to it, with property LHost or SHost ( LampHost and SpotHost)-(need to rename them becaue they are lamps not holders :/)

and light hooks have the properties - LHook, Energy and Type , and the object color of the hook stores the color value of the lamp.

import bge



def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner
    
    if 'Lights' not in own:
        Lights=[]
        Spots=[]
        for child in own.children:
            if 'Host' in child:
                Lights.append(child)
            if 'SHost' in child:
                Spots.append(child)
                child.setOcclusion(False, False)    
            child.removeParent()
        own['Lights']=Lights
        own['Spots']=Spots
        print('set lights list')
        Hooks=[]
        SHooks=[]
        for objects in bge.logic.getCurrentScene().objects:
            if 'LHook' in objects:
               Hooks.append(objects)
            if 'SHook' in objects:
                SHooks.append(objects)
                   
        own['Hooks']=Hooks
        own['SHooks']=SHooks       
        
    else:
        
                
        lamps = own['Lights'].copy()
        spots = own['Spots'].copy()
        sortStart=[]
        sortStart2=[]
        index=0
        in_use=[]
        for Hooks in own['Hooks']:
            sortStart.append([Hooks,own.getDistanceTo(Hooks)])
        for SHooks in own['SHooks']:
            sortStart2.append([SHooks,own.getDistanceTo(SHooks)])
            
            
        sortedHooks = sorted(sortStart, key=lambda tup: tup[1])   
        sortedHooks2 = sorted(sortStart2, key=lambda tup: tup[1])   
        for Hooks in sortedHooks:
            if len(lamps)!=0:
                Hooks[0]['LHook']=lamps[0]
                lamps[0].energy=Hooks[0]['Energy']
                lamps[0]['Host']=Hooks[0]
                lamps[0].worldPosition=Hooks[0].worldPosition
                lamps[0].color = (Hooks[0].color[0],Hooks[0].color[1],Hooks[0].color[2])
                
                lamps[0].children[0].color=Hooks[0].color
                lamps[0].setParent(Hooks[0])
                lamps.pop(0)    
        
        
        read=[]
        for Hooks in sortedHooks2:
            if len(spots)!=0:
                Hooks[0]['LHook']=spots[0]
                spots[0].energy=Hooks[0]['Energy']
                spots[0]['Host']=Hooks[0]
                spots[0].worldPosition=Hooks[0].worldPosition
                spots[0].color = (Hooks[0].color[0],Hooks[0].color[1],Hooks[0].color[2])
                spots[0].worldOrientation=Hooks[0].worldOrientation
                spots[0].children[0].color=Hooks[0].color
                spots[0].setParent(Hooks[0])
                spots[0].children[0].worldPosition=own.worldPosition+(own.worldOrientation.col[1]*1.5)
                read.append(Hooks[0])
                own['Read']=str(read)
                spots.pop(0)          
                  
            
            
                        
                
                
                
                


main()



yes, but lights on the unused layer still use resources.

I’m not sure that’s the case, compared to when I used to have all the lights in the active layer, ever since I started placing lights into the inactive layers, the rasterizer had become very quiet, it will only go crazy if I spawn them all at once

I’m not sure that’s the case

be sure. i have tested it with 1024 lamps. got a framerate of 6.7 on layer 1 with the lamps on layer 2. moving lamps sounds good

The idea of the dynamic lighting might work if the game I’m making wouldn’t be intended for split screen, but since two characters will be in the scene at the same time, I’m not sure how well that would work, I tested 16 lights and that worked, but with the graphics level I had, I think it won’t work very well.

be sure. i have tested it with 1024 lamps. got a framerate of 6.7 on layer 1 with the lamps on layer 2. moving lamps sounds good

This is odd, can you show me a blend? I tried adding a thousand sun lamp copies with shadow enabled inside layer 2 and then press P in layer 1 and nothing happened, rasterizer didn’t build up, are you using windows blender or linux/mac? It could be a bug if your rasterizer is still spiking