Cycles control of Env Image lighting with nodes

I was using an environment image recently in cycles and wanted the environment image to throw more light on the scene. Dialling up the strength of the background shader certainly increases the light coming from the Env image but unfortunately it also brightens the env image itself in the picture. So I was sometimes finding that when I got it throwing enough light to light the scene it was blowing out the light parts of the env image in the render.

After a bit of hunting about I came upon a node group by Greg Zaal that aimed to provide control in such a circumstance.
It worked but ( and excuse my presumption!) but I thought I could improve it possibly. In particular I found that the management of the light path information was a) incomplete and b) not as clear in its logic as I thought it could be.

I think I may have found an improved version of that node group so Im showing it here .

My other reason for posting is that I couldn’t find a specific Bender Artists thread about this topic. So Ill post my node group and its logic. You can all tear it apart and if you have better approaches then please post them.

Ok to business.

My node group is basically the same in its general outline as the one at http://blender.stackexchange.com/questions/518/how-to-make-a-model-cast-shadows-onto-the-world-texture-background/26686#26686

Here is the node group. I have grouped the nodes handling the light paths because that’s the main bit I want to concentrate on.

the basic noodle:


Nothing startling here. Its basically the same node group that I gave the link for but with an additional control that allows you to control how bright the env image is in the rendered image. Env Lighting Strength adjusts the amount of light thrown to the scene by the env map and env image strength controls how bright the env image is in the render.

The color mix on the right is essentially a switch which detrmines which noodle path calculates the strength. If Fac is 1 on the color mix on the right then the bottom noodle path is used, if its 0 then the other path is used.

The trick is to switch which path is used depending on the type of ray being calculated. The color mix on the right needs to use the bottom path (ie be Fac 1) if its a camera ray and use the other path ( with the env light strength) if its another type of ray. That way we can use a different strength for the env image depending on what ray is being handled.

What we need then is a bit of a noddle that will handle that logic for us. Thats were the light Path Logic node group comes in.

Ill post this now and continue in a further post.

Part 2.

Ok so now Im going to look at how we can create a logic group to control the color mix switch that I referred to earlier.

this is the expanded Ray Logic group from the earlier picture -


here is where my approach differs from the one I gave the link to.
in that nodle the logic only handled a test between isCameraRay and isGlossyray . I couldnt quite get my head round this. ( which may be down to me being dumb of course!)

It seems to me that if you want extra light from your env map then you wany that light to influence diffuse, glossy, transluscent etc. Basically everything but the actual camera ray light strength.

So I tried adding these extra ones in. The calculation of the switch value in the original node group uses a color mix node set to Add. For me ( maybe not for others!) this seemed less than intuitive and I wanted a node group that would handle these other ray types and be a bit more obvious in what it was doing.

my solution was to use something that looks a bit more like a logic group by using greater than test which is what you see in the expanded group.

It seems to work well, I think its clear what its doing and you get independent control of the light strength of the env image and of the strength of the env image in the render.

Anyone got any other approaches? Any thoughts on this issue?

Im going to criticise my own approach here. Reading Greg Zaals original comments on the node group I see his logic for treating the handling of the Camera ray and the glossy ray together. The glossy ray needs to show the env Image at the strength the camera sees it at so that reflections look right. My node group is incorrect therefore in the way it handles the glossy ray. It should be handled with the camera ray. Im not sure I was right that my noodle improves on the original approach. The penalty of premature posting perhaps! Mine works BUT I didn’t test how it handles glossy reflections!

Ok some more noodling and I think the overall node group can be reduced to this;


and the Ray logic reduced back to this which is Greg Zaals one rather than the one in the Blender Stack exchange answer.


This seems to me to do the job and is overall quite a simple setup.