Page 1 of 1

Light and Layers

PostPosted: Sun Oct 10, 2010 12:17 pm
by dendwaler
A (Sun) light normally effects the lightning in the whole world.
In Blender is an option that to let it have only effect in the same layer as where the light is in.
I want to make use of this option and want to exclude the sunlight inside closed buildings, but I don't succeed nor see any difference in Plasma.
May be I do something wrong but I wonder
Is this option supported in PyPRP?

if not, is there a known workaround?

Re: Light and Layers

PostPosted: Sun Oct 10, 2010 3:06 pm
by D'Lanor
Nope, PyPRP does not support that. If you want to control which materials are affected by a light you have use light groups.

And (as you probably know already) if you want to limit the effect of a light on the avatar you use soft volumes.

Re: Light and Layers

PostPosted: Sun Oct 17, 2010 12:35 pm
by DanTheMystFan
If you're interested, I have modified my own PyPRP copy to assign lights to objects based on any group an object has in common with a light. In prp_DrawClasses.py, replace this:

Code: Select all
            # Only add lights for this icicle if we are not "SHADELESS"
            if not mat.mode & Blender.Material.Modes["SHADELESS"]:
                if not lightGroup == None:
                    # if a lightgroup is set, use those lights, else use all lights in the page....
                    for pllamp in lights:
                        for lobj in list(lightGroup.objects):
                            dataname = lobj.getData(True) # First param sets return of name only
                            if str(pllamp.data.Key.name) == lobj.name or str(pllamp.data.Key.name) == dataname:
                                mylights.append(pllamp)

with this:

Code: Select all
            # Only add lights for this icicle if we are not "SHADELESS"
            if not mat.mode & Blender.Material.Modes["SHADELESS"]:
                for group in Blender.Group.Get(): #get list of groups
                    if obj in list(group.objects):
                        #current object is in current group
                        for pllamp in lights:
                            if (not pllamp in mylights):
                            #go through all lamps not already appended
                                for lobj in list(group.objects):
                                    if str(pllamp.data.Key.name) == lobj.name or str(pllamp.data.Key.name) == lobj.getData(True):
                                        mylights.append(pllamp)


EDIT: One other thing--if you've installed PyCo, you have to delete all the .pyc files in the PyPRP directory before this change will take effect.
The other thing you should know is that by default, *no* lights will affect any objects--you'll have to put all of your outdoor objects in a group with your sun and your indoor objects in a group with your indoor lights.
Also, as was mentioned, this won't affect avatars--you'll have to use SoftVolumes for that.

EDIT2: One other thing I should add--if your sun(or, for that matter, any of your other lights) doesn't animate at all, you should probably just use vertex painting to simulate the effect.

EDIT3: Unlike the current code, my code uses the groups under "Objects and Links," NOT lightgroups.

Re: Light and Layers

PostPosted: Tue Oct 19, 2010 11:12 am
by dendwaler
Thx for sharing this code!
I am going to play with it next week and hopefully i can benefit from it.