Translucency is very costy for mobile game, ususally not advised to use. Although artist would often insist using them. One trick I found to optimize this kind of material is using reflection information to fake transparent object.
I experimented with 2 different implementations, each has its own quirkness.
The basic idea is to modiy the material’s normal to an angle so that reflection ray will sample directly the scene behind object, and lerp the normal to reflection ray to simulate IOR. But the orinigal normal is lost now – Luckily, UE provide us the buildin clearcoat shading model to solve our problem. Simply use the bentnormal for our reflection. This is easy to implement without any extra effort. However, since pixel normal node can’t be connected to material normal output, it will result in some intepolating artifect.
The first method can solve the problem above, by adding custom material experssion node and modifying the engine shader code.
// Insert after Sampling SpecularIBL
#if NUM_MATERIAL_OUTPUTS_GETIOR > 0
// reflection
float a = GBuffer.Specular;
SpecularIBLLighting *= a;
float IOR = GetIOR0(MaterialParameters);
MaterialParameters.ReflectionVector = refract(-MaterialParameters.CameraVector, MaterialParameters.WorldNormal, 1.0/IOR);
// refraction
SpecularIBL = GetImageBasedReflectionLighting(MaterialParameters, GBuffer.Roughness, IndirectIrradiance, 1-a) * ShadingModelContext.EnvBrdf;
SpecularIBLLighting += SpecularIBL;
#endif
The code does the same thing as method 1, it modify reflectionVector and use it to sample reflection probe. I also reuse the specular input as lerp factor to adjust the transluceny.
NUM_MATERIAL_OUTPUTS_GETIOR and GetIOR0 are both defined in custom material experssion node, It allow us to change the shader behavior without adding extra shading model, which is limited in number and requrie recomiling engine.
The second method doesn’t use reflection inforamtion at all, instead just sample a cubemap. This allow us to use scene capture in editor and solve the issue of multiple fake tranparent, because if we rely one the reflection method, all other object will apear black. The method do has higher cost since it generally require one cubemap texture per object. To make the setup easier, it’s better to use editor BP to automately create cubemap and appied to new MID.