《MentalRay 环境模拟》由会员分享,可在线阅读,更多相关《MentalRay 环境模拟(16页珍藏版)》请在金锄头文库上搜索。
1、.MentalRay环境模拟这篇教程翻译的不是很好,有些术语不懂,请高人查缺补漏,修改一下,以免误人子弟。IreadathreadwhichwasstartedbyFilipOrrby,inwhichheasked“HowtomakeobjectnotblockFGrays?”.HewentontoanswerhisownquestionandsinceitissimilartoatechniqueIuse,Idecidedtoelaborate.我读到一个人询问“如何让物体不阻塞FG射线?”他的答案和以前我用到的一种技术很相似。我在这里详细阐述一下。Imgoingtowriteaboutas
2、haderandlightingsetupIuseafairbitforproductshots,wherethebackgroundisverysimple,oftenwhiteandtheproductistobebrightlylit.FormyfinalrendersIusuallybreakthingsintorenderlayers,butIliketobeabletoquicklyrendereverythinginonepasstoevaluatemyanimationandtoshowmyprogresstotheclient.我正要写一篇我经常使用的shader以及一个照明
3、设置的文章,这种技巧经常被用于我的产品展示渲染,这个设置背景很简单,经常是白色背景,能使产品看上去更加光亮一些。在最后的渲染中经常将物体渲染出不同的层通道,但我也喜欢在给客户展示时,会将所有物体放到一个Pass中渲染,以节省时间。Hereisatypicalexampleoftheendresult.这是典型的最终结果Toseeastep-by-stepbreakdownofthesetup,clickhereMylightingisphysicalsun/skyusingfinalgather.MybackgroundisasimplefileTextureofacloudyskyabove
4、awhitegroundwhichIhavemappedontoaflattenedsphere.Youcandownloadmyscenefilehere.我使用了物理天光系统,背景是一个简单的天空文件贴图,地面是白色的压扁的球体。你可以点击这里下载源文件。Hereisasnapshotofthewireframe.线框的截图andthisisasmallversionoftheskymap天空贴图Theproblemisthattheflattenedsphereblocksthefinal-gatherraysfromthephysicalsky.Icouldjustlivewithit
5、andusethespheresurfacewithitsfiletextureasafinal-gatherradiator.AndIwouldgetsomthinglikethis问题是扁平的球体阻挡了来自天光的FG射线。我只能将带着贴图的球体作为FG的散射器了,如下图所示。Asyoucanseetheresultisstillgoodandisnotdrasticallydifferenttothefirstimage.ButmybackgroundimageismostlywhitewithabitofblueandthisdrivesthelookoftheFGgivingitane
6、utralfeel.Comparethiswiththefirstimagewhere,duetothelowangleofthesun,thereisanoticeablewarmlooktotheFG.So,howdowestopthesphereblockingtheFG?Theansweris,byusingmib_continueandmip_rayswitch.你可以看到渲染结果还是可以的,和第一张图比起来显著的差异,我的背景图片大部分是白色的,带着一点蓝色,这样可以使FG射线呈现一个自然的效果。对比第一张图片,将物理天光灯光的阳光的角度调低,可以获得一个显而易见的暖色调效果。那么
7、,我们怎样才能不让球体阻挡FG射线呢?答案就是使用mib_continue和mip_rayswitch节点。mip_rayswitchenablesdifferentshaderstobeuseddependingonthetypeofraythatisbeingcalculated.Havealookattheattributesheretoseethedifferenttypeofraysthatcanbesingledout.mip_rayswitch节点可以将不同的Shaders作为不同类型的射线来计算使用。看看它的属性面板,有许多不同类型的射线可以单独的分离出来。Illjustmen
8、tiontwooftheminthisexample.Theeyeraysaretheonesyouactuallyseeintherenderedimage,sothatiswhereIconnecttheshaderthatIwantformybackgroundcolor.ThefinalgatherraysareusedintheFGcalculationsanditishereIconnectthemib_continueshader.在我们这个例子中我将仅仅涉及到它们中的两种,Eye射线是你实际上看到的渲染出来的图像,所以我将希望我的背景呈现的颜色连接给这个Shader。FG射线会
9、在FG计算中用到,这里我将它连接给一个mib_continue节点。mib_continueisashaderthattakesanyincommingrayandsimplyletsitcontinueonthroughthesurfaceasifthesurfacewasnoteventhere.SoinmyexampleitletstheFGraysfromthephysicalskycontinuethroughtheflattenedsphere.InthiscaseImjustusingthemib_continuewithitsdefaultattributes.mib_cont
10、inue节点是一个接受任何入射光线,让其穿过模型表面就像表面不存在一样。在这个例子中,我让FG射线从物理天光发射出来穿过球体。我使用mib_continue节点的默认设置。Sothatisthebasisofmysetup,buttomakeitworkthereareafewmorethingstoconsider.这就是我的设想,但是做要比想难很多倍。Firstly,Iamusingmia_exposure_photographictonemapperasalensshaderwithgamma=2.2foralinearworkflow.ThismeansIneedtoincreaset
11、hebrightnessofmybackgroundtexturemaptoboostitintothesamedynamicrangeasthephysicalsky.IfIdont,thenthebackgroundwillbeblack!AndIneedtode-gammathefileTexturesincethegammawillbeaddedbythetonemapper.首先,我是用一个mia_exposure_photographictonemapper作为一个镜头shader将Gamma值调节为2.2。这意味着我需要增加背景图片的亮度来迎合物理天光的高动态范围。如果我不这样做
12、,背景图片在高动态的物理天光的照射下依旧是黑色的。同时由于Gamma数值会被toneMap贴图加大,我需要减少文件贴图的Gamma值。Secondly,Iamusingthemip_matteshadowshaderwithmyownspinonitforcoloringtheflattenedsphere.Illdomybesttoexplain:mip_matteshadowisamorepowerfulversionofmayasnativeuseBackgroundshader.Itisnormallyusedtocatchshadows,occlusion,reflectionsan
13、dindirectlightingforcompositinglaterandsupportsmultipleoutputs.ButIamusingitasawayofdoingthatcompositingwithintherender.Reason1:itmakesiteasytogetshadowsonasurfacethatisnototherwiseilluminatedbyanylights.Reason2:itmakesiteasytogetreflectionsonverylightcolored(orwhite)surfaces,becauseitcandosubtracti
14、vereflections.(Ididntusereflectionsinmyexamplethough.)Reason3:WhenIgettomyfinalrendersphase,IcaneasilybreakoutthecomponentsIneedintodifferentrenderlayerswithouthavingtochangetoomanythings.第二,我需要mip_matteshadow节点,来生成扁平球体的色调,我来解释一下:mip_matteshadow节点比Maya自带的Usebacgground节点要强大很多,一般用于分离阴影、阻塞、反射、和间接光照用于后期
15、合成以及支持多种输出。我只是用它在渲染中进行合成,1.因为很容易获得阴影而且不受其他灯光的影响。2.他很容易从受灯光颜色影响很少(或者是白色)的物体上获得反射效果,因为他无需改变其他东西就可以进行负反射。3.当我进入最后渲染阶段时,我不用更改大量的属性而将我需要的属性分离到渲染层中。Thirdly,Iamusingmib_amb_occlusioninsteadofusingmip_matteshadowsocclusionfeature.ThereasonisthatIoftenaddnurbs-planestoactasfinal-gathercasters,muchlikeyouwoul
16、dusediffuselightsorreflectorcardsinarealphotoshoot.Theseplaneswillhaveprimaryvisibilityoff,butIdonotwhatthemtooccludethegroundinanyway.mib_amb_occlusionhasanidNonselfattributethatcanbeusedtopreventobjectsfrombeingconsideredforambientocclusion.第三,我使用mib_amb_occlusion节点来替代mip_matteshadow节点的OCC功能,因为我常常将NURBS平面作为FG的底板。也许大多数人使用灯光阵列和反射板来模拟真实环境,这些物体经常是不可见的,但是我不想它们产生任何OCC的影响,我使用mi