Совокупление mip_matteshadow и IBL

Недавно немало помучался с тем как же заставить mip_matteshadow шейдер отображать сквозь себя текстуру IBL. В примерах повсеместно используется mip_mirrorball и mip_cameramap, но чего делать с обычным latlong изображением – ничего не нашел. Хотя видел предложение воспользоваться mib_lookup_spherical, но по-моему синхронизировать этот шейдер с вращениями IBL – большое западло. Сейчас опишу наденное мною простое и полезное решение.

IBL and ground plane to catch shadows

IBL and ground plane to catch shadows

Оно крайне простое – воткнуть в background канал mip_matteshadow шейдера mia_envBlur без подключенного environment:

mia_envBlur reveals IBL in mip_matteshadow

mia_envBlur reveals IBL in mip_matteshadow

Передняя сфера, уходящая под “землю”, корректно обрезается. Если нужно получить сплошную альфу, можно попросту воспользоваться mib_color_mix:

Replacing alpha to solid

Replacing alpha to solid

И это, собственно, все 🙂

Если под землю ничего не проваливается, можно воспользоваться альтернативным методом – вместо mia_envBlur подключить mib_opacity или mib_transparency с нулевой непрозрачностью или полной прозрачностью соответственно. При наличии хотя бы одного refraction луча в плейне увидим IBL. Разница между двумя лишь в альфе – mib_opacity выдает сплошную:

mib_opacity reveals IBL in mip_matteshadow

mib_opacity reveals IBL in mip_matteshadow

а mib_transparency только от теней:

mib_transparency reveals IBL in mip_matteshadow

mib_transparency reveals IBL in mip_matteshadow

P.S. В качестве карты окружения использовал uffizi_probe.hdr, сконверченную в latlong:

http://www.debevec.org/probes/

8 Responses

Subscribe to comments via RSS

  1. Written by donGuzzini
    on 18 June 2009 at 0:19
    Permalink

    Спасибо за инфу, очень полезно, использовал в проекте.

  2. Written by matt
    on 28 June 2009 at 12:40
    Permalink

    hey,

    excellent post, thank you! found your site through cgtalk, looking forward to reading more.

    quick question – would you know the procedure for getting a shadow pass (from either useBackgroundShader, or mip_matte_shadow) to show up visible in refractions or reflections on a mia_material or a regular maya shader? need to refract shadow pass for compositing, don’t know what to do!

    cheers,

    m

  3. Written by Sagroth
    on 28 June 2009 at 14:35
    Permalink

    Hi, Matt.

    Since your shadows are visible through glass, they are actually considered as refraction data. I doubt that automatic pass system would return a correct result right away, so the most reliable way, in my opinion, is to make a special renderLayer with network you want and render it separately – try making your mia_material glass 100% refractive (so it doesn’t appear in alpha) and assign mip_rayswitch to objects behind it. In eye it should be invisible (mib_continue) and in refraction use ‘mib_transparency -> mip_matteshadow’ technique I’ve mentioned. That way in alpha you should get just shadows, refracted through glass.

    I hope that helps. Let me know the results, please 🙂

    P.S. Since you use that transparency trick – you should plug mib_continue into transparency for mip_rayswitch also.

  4. Written by Jesus
    on 19 July 2009 at 19:34
    Permalink

    Hi,

    Excellent and simple solution! Thanks!

    I have a question. I’m using sIBL (http://www.hdrlabs.com) and cannot get this to work using that. I’m wondering if it’s related to the mip_rayswitch. Do I need to make a connection using the mip_matteshadow when using mip_rayswitch? If so, where do I plug this in? I’m so confused about this.

  5. Written by Sagroth
    on 19 July 2009 at 21:16
    Permalink

    Hi.

    I fear I’ve never used sIBL, so don’t know why it doesn’t work, but thanks for the link – it looks pretty interesting and I’ll try it out.

    You need mip_rayswitch only if you want to make your objects render black in direct visibility and with shadows in refractions – ‘shadows through glass’ pass, let’s say. For that you need to plug mib_continue into eye and transparency slots of mip_rayswitch, mip_matteshadow into refraction slot and mib_transparency into mip_matteshadow.background (and mip_rayswitch itself into a constant shader that you assign to those objects, surfaceShader for example – outValue into outColor and outValueA into outMatteOpacityR, G and B).

    That works through glass made via mia_material shader – I did no tests for other situations.

  6. Written by dub73
    on 17 December 2010 at 20:01
    Permalink

    thanks dude, you saved my day !! 🙂 so … easy

  7. Written by SLO
    on 20 July 2012 at 9:40
    Permalink

    Благодарю!

  8. Written by Eduardo
    on 14 April 2014 at 21:15
    Permalink

    Brother, I love you. Really thankful

Subscribe to comments via RSS

Leave a Reply