Page MenuHome

Cycles: Add option to make lamps directly visible to the camera
Needs RevisionPublic

Authored by Lukas Stockner (lukasstockner97) on May 24 2018, 10:53 PM.

Diff Detail

rB Blender
Build Status
Buildable 1702
Build 1702: arc lint + arc unit

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.May 26 2018, 3:47 PM

For meshes and world this is controlled through Ray Visibility > Camera.

I think we use the same terminology, and maybe just make the existing ray visibility setting on the object work? The tricky part is that's it's not possible for custom properties to have a different default for lamp objects, though I guess we can work around that by having a different property for lamps that still shows with the same name in the UI?

This revision now requires changes to proceed.May 26 2018, 3:47 PM

Yes, that definitely is a better place for it.

Brecht Van Lommel (brecht) requested changes to this revision.May 28 2018, 12:00 AM

Enabling this seems to make all lamps in the scene visible? I think we should set SHADER_EXCLUDE_CAMERA for lamps and then handle it in indirect_lamp_emission?


Spelling: separate


Can we rename this to use_camera too?

This revision now requires changes to proceed.May 28 2018, 12:00 AM

This has more than a year.

Even when there are possibly better solutions to handle this, being a needed feature for production and being a rather simple one, can't we have this implemented in master as it is right now (maybe under experimental) and leave the improvements for later?

Or course this won't fit any case, but this is a rather important feature since we have to rely on less efficient geometry lights to have the actual light visible.

BTW IMHO Visibility shoud be ON by default, it's a user/artistic decission to hid the light from the camera, in real life you don't hide bulbs from the camera, so I don't see a problem in using the same "Use Camera" setting that is there for any other object.

Juan Gea (juang3d) added a comment.EditedSep 4 2019, 4:27 PM

OK, I updated this to 2.81 and it works.

I've found two problems that may be super easy to fix for any of you, @Lukas Stockner (lukasstockner97) or @Brecht Van Lommel (brecht) but they have me kind of puzzled, since you probably don't have time to tackle this for the time being, any clue that you could give me to investigate it is very welcome.

First problem: the light is "transparent", it depends on it's power to be more or less transparent, this is not a big problem, and can even be desirable, but I would love to understand why is this happening.

Second problem, you already mentioned it @Brecht Van Lommel (brecht) , if the setting is enable in ANY light, it will affect all the lights in the scene, you also mentioned SHADER_EXCLUDE_CAMERA and handling it on "indirect_lamp_emission", can you point me towards the location of those two parts and/or something similar?


EDIT: Ok, found both things, the EXCLUDE flag and the function, trying to wrap my head around them :)

After fighting with this all day, I think that I know why all the lights are enabled/disabled all at once, correct me if I'm wrong, but this


Seems to be picking a variable that is a global one, each light is overwriting it, so once you have no lights with use_lamp_direct enabled, the value is false, but as soon as you have one light with this enabled, then the value is true, but in general, not per light.

I'm still trying to figure out how this works, because I have no idea on how can I change "SHADER_EXCLUDE_CAMERA " for an specific light.

LightManager::device_update_points sets the shader exclude flags for lights, I think you would just set SHADER_EXCLUDE_CAMERA based on if (!light->is_direct) there as well.

In indirect_lamp_emission you probably just need to copy indirect_background, and add this line:

((shader & SHADER_EXCLUDE_CAMERA) && (state->flag & PATH_RAY_CAMERA)) ||

Uploaded a new diff in a different patch with updates to this: