Home Unreal Engine

Using opacity masks with refraction on translucent materials.

Hi guys, new to these forums and relatively new to UE4 - I come in search of help if possible.

I'm trying to create broken glass, the mesh is just a flat plane and I'm using an alpha to create the shape of the broken glass. On top of that i'm using a refraction input with translucent shader, to give varying amounts of refraction to make it look old and dirty in areas. Problem is the refraction is applied to the whole plane, rather than just where the broken glass should be as per the mask - see screen grab. I'd be happy enough with this current result if it was just cut out properly.

Maybe I'm going about this wrong but feels like I've tried everything including changing the blend modes, sampler type for the refraction input map (which also has a mask in the alpha channel of the map itself, idea being - so it doesn't use black as the refraction value for bits that need to be totally invisible, which I think is what's happening). I also tried a solid black and white map in the opacity slot to create the broken glass shape along with the same 'patchy' refraction map but this worked out even worse (no refraction on the glass areas, then the same refraction error on the bits that should be cut out). I've attached a screen grab of my current material set up and map I'm currently using for the opacity/refraction.

Hope this makes sense. It might be something really obvious but any help would be much appreciated.

Replies

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Have you tried looking into the official documentation? They have an example of how refraction works in Unreal. Basically you need to put some extra nodes and tell if to use ior of 1.52 where you want refraction on the glass, and ior of 1 where you dont want any.
    https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/Refraction/index.html
    And in your case, the fresnel node should be multiplied by the inverse of your alpha map before feeding it to the lerp alpha.
  • SteveWeener
    Thanks for your reply, and apologies for the delay, just got round to playing with this again. 

    I went over the link to the official documentation and this helped alot, thanks for pointing me in the right direction. Don't know why I didn't think of looking there before!

    I was having issues with the fresnel node at first (like before it was still creating some refraction on the bits that need to be cut out), then I realized i wasn't the inverse of the alpha I needed to multiply the fresnel node by, but just the alpha itself (I used the mask I put in in the alpha channel of the refraction/opacity map - white where there is glass, solid black on the cut out bits) and it works nicely now. Probably really simple stuff but I've put a screen grab in incase it helps anybody else.

    Now I've got it working I can play about with refining it - thanks alot!

Sign In or Register to comment.