Copulating mip_matteshadow & IBL

Just recently had a lot of headache trying to force mip_matteshadow shader to reveal IBL texture through itself. Multiple examples on the web utilize mip_mirrorball and mip_cameramap, but what to do with simple latlong image – found nothing. Actually, there were suggestions to use mib_lookup_spherical, but in my opinion synchronizing it with IBL rotations is a pain in the ass. I’ll describe a simple and useful solution I’ve found.

IBL and ground plane to catch shadows

IBL and ground plane to catch shadows

It’s really simple – just plug mia_envBlur without any environment into background channel of mip_matteshadow shader:

mia_envBlur reveals IBL in mip_matteshadow

mia_envBlur reveals IBL in mip_matteshadow

Frontal sphere that falls beneath the ground plane is correctly cut. If you need to get a solid alpha – just use mib_color_mix:

Replacing alpha to solid

Replacing alpha to solid

And that’s it, actually 🙂

If nothing is beneath the ground in the scene an alternative could be used – instead of mia_envBlur plug in mib_opacity or mib_transparency with zero opacity or full transparency accordingly. Having at least one refraction ray, ground plane will reveal IBL. The difference between the two is in alpha – mib_opacity returns solid one:

mib_opacity reveals IBL in mip_matteshadow

mib_opacity reveals IBL in mip_matteshadow

and mib_transparency just from shadows:

mib_transparency reveals IBL in mip_matteshadow

mib_transparency reveals IBL in mip_matteshadow

P.S. As an environment map I’ve used uffizi_probe.hdr converted to 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