I read a thread on cgTalk, which was started by Filip Orrby, in which he asked “How to make object not block FG rays?”. He went on to answer his own question and since it is similar to a technique I use, I decided to elaborate.



I’m going to write about a shader and lighting setup I use a fair bit for product shots, where the background is very simple, often white and the product is to be brightly lit. For my final renders I usually break things into render layers, but I like to be able to quickly render everything in one pass to evaluate my animation and to show my progress to the client.





Here is a typical example of the end result.



To see a step-by-step breakdown of the setup, click here

My lighting is physical sun/sky using final gather. My background is a simple fileTexture of a cloudy sky above a white ground which I have mapped onto a flattened sphere. You can download my scene file here.






Here is a snapshot of the wireframe.




and this is a small version of the sky map



The problem is that the flattened sphere blocks the final-gather rays from the physical sky. I could just live with it and use the sphere surface with its file texture as a final-gather radiator. And I would get somthing like this




As you can see the result is still good and is not drastically different to the first image. But my background image is mostly white with a bit of blue and this drives the look of the FG giving it a neutral feel. Compare this with the first image where, due to the low angle of the sun, there is a noticeable warm look to the FG.

So, how do we stop the sphere blocking the FG? The answer is, by using mib_continue and mip_rayswitch.





那么,我们怎样才能不让球体阻挡FG射线呢?答案就是使用mib_continue 和 mip_rayswitch节点。


mip_rayswitch enables different shaders to be used depending on the type of ray that is being calculated. Have a look at the attributes here to see the different type of rays that can be singled out.




I’ll just mention two of them in this example. The eye rays are the ones you actually see in the rendered image, so that is where I connect the shader that I want for my background color. The finalgather rays are used in the FG calculations and it is here I connect the mib_continue shader.


在我们这个例子中我将仅仅涉及到它们中的两种,Eye 射线是你实际上看到的渲染出来的图像,所以我将希望我的背景呈现的颜色连接给这个Shader。FG射线会在FG计算中用到,这里我将它连接给一个mib_continue节点。


mib_continue is a shader that takes any incomming ray and simply lets it continue on through the surface as if the surface was not even there. So in my example it lets the FG rays from the physical sky continue through the flattened sphere. In this case I’m just using the mib_continue with it’s default attributes.




So that is the basis of my setup, but to make it work there are a few more things to consider.





Firstly, I am using mia_exposure_photographic tone mapper as a lens shader with gamma=2.2 for a linear workflow. This means I need to increase the brightness of my background texture map to boost it into the same dynamic range as the physical sky. If I dont, then the background will be black! And I need to de-gamma the fileTexture since the gamma will be added by the tone mapper.


首先,我是用一个mia_exposure_photographic tone mapper作为一个镜头shader将Gamma值调节为2.2。这意味着我需要增加背景图片的亮度来迎合物理天光的高动态范围。如果我不这样做,背景图片在高动态的物理天光的照射下依旧是黑色的。同时由于Gamma数值会被tone Map贴图加大,我需要减少文件贴图的Gamma值。


Secondly, I am using the mip_matteshadow shader with my own spin on it for coloring the flattened sphere. I’ll do my best to explain: mip_matteshadow is a more powerful version of maya’s native useBackground shader. It is normally used to catch shadows, occlusion, reflections and indirect lighting for compositing later and supports multiple outputs. But I am using it as a way of doing that compositing within the render.


Reason 1: it makes it easy to get shadows on a surface that is not otherwise illuminated by any lights.


Reason 2: it makes it easy to get reflections on very light colored (or white) surfaces, because it can do subtractive reflections. (I didnt use reflections in my example though.)


Reason 3: When I get to my final renders phase, I can easily break out the components I need into different renderlayers without having to change too many things.













Thirdly, I am using mib_amb_occlusion instead of using mip_matteshadow’s occlusion feature. The reason is that I often add nurbs-planes to act as final-gather casters, much like you would use diffuse lights or reflector cards in a real photo shoot. These planes will have primary visibility off, but I do not what them to occlude the ground in any way. mib_amb_occlusion has an idNonself attribute that can be used to prevent objects from being considered for ambient occlusion.


第三,我使用mib_amb_occlusion节点来替代mip_matteshadow节点的 OCC功能,因为我常常将NURBS平面作为FG的底板。也许大多数人使用灯光阵列和反射板来模拟真实环境,这些物体经常是不可见的,但是我不想它们产生任何OCC的影响,我使用mib_amb_occlusion节点的idNonself属性来防止物体被计算到AO中。


Notice how I have set idNonself=5 . If I add an extra attribute called miLabel to an object’s transform node and set its value to the same number, in this case 5, then it will be ignored by the ambient occlusion. Here is how it looks on the bgndSphere transform node






So now, to bring all this together, I just need to show you the hypershader network (click image for a larger version that you can actually read).




I’ll explain the connections from left to right.

The fileTexture connects to the gammaCorrect node with a value of 0.455 (1/2.2)




文件节点连接到gammaCorrect节点,调节的数值时1/2.2(mia_exposure_photographicd 的Gamma值)=0.4545


mib_amb_occlusion is combined with the background color using a mib_color_mix node, where the occlusion layer is multiplied over the background color.


mib_amb_occlusion 是用mib_color_mix节点与背景颜色联合使用,OCC层正片叠底在背景颜色上。


The combined result is then multiplied by 20000 to bring it into roughly the same dynamic range as the physical sky and counter the effect of the exposure node lens shader. This number, 20000, was determined through trial-and-error (but after doing this for I while, I’ve got fairly good at guessing).




The very bright background color is then connected to the eye ray of the mip_rayswitch where it is combined with finalgather ray from the mib_continue node (shown earlier).


非常亮的背景颜色连接到mip_rayswitch的sye ray上,mip_rayswitch的finalgather连接了mib_continue节点,让FG射线穿过背景的表面。



The output of mip_rayswitch is fed into the mip_matteshadow background color. And mip_matteshadow is connected to the SG node as the miMaterialShader. (The lambert shown has no effect on the render, but is useful for being able to select assigned objects from the hypershade rmb-menu)


mip_rayswitch节点的输出连接到mip_matteshadow的background上,mip_matteshadow节点连接背景表面材质原Lanbert的SG的material shader上(现在Lambert材质在渲染中没有任何作用了,但是仍然能够通过它来选择到场景中的相关物体)


Have a look at the mip_matteshadow attributes



It is not obvious but the Ambient color is set to 20000, 20000, 20000 (just like the multiply value I used before). This setting is required so that the Shadows color will work properly.

Ok. Thats it. Longer than I expected.


虽然不明显,但是Ambient color已经设置成为20000,20000,20000(就是前面我使用的multiply值),这个数值时让阴影颜色正确所需要的。



I use this set up quite a bit so some of it’s wierdness has disappeared and it feels quite comfortable. It doesnt replace the use of render layers and good compositing, but it is great for those early work-in-progress renders. Hopefully you saw some ideas here that you could use in your own work.









电子邮件地址不会被公开。 必填项已用*标注

验证问题,请选择下图中的 D...