CandelaSSRR in Unity 5

CandelaSSRR works out-of-the-box in Unity 5 ( at least in deferred mode ), but all surfaces are at maximum reflectivity regardless of the alpha parameter. How to make it work with the standard shader ?

The reason why everything is shiny is that the output alpha buffer is always all white (as can be seen in the frame debugger and the alpha of the scene view).

This is due to the way Unity resolves the GBuffers : UNITY_BRDF_PBS() always outputs 1 to the alpha channel.

Steps to fix this :

  • Download the Unity 5 shaders that match your beta version (mine is 21)

  • Copy DefaultResourcesExtra/StandardSpecular.shader, CGIncludes/UnityStandardCore.unity and DefaultResourcesExtra/Internal-DeferredShading.cginc anywhere in your Assets/ folder.

  • Rename all of them with a “_Custom” prefix (not sure if really needed)

  • Make the deferred renderer output the alpha channel : at the very end of UnityStandardCore_Custom.cginc, remplace

    outDiffuse = half4(s.diffColor, 0.0);


outDiffuse = half4(s.diffColor, s.alpha)
  • Make your Custom Standard Shader use this function instead of the built-in one : in StandardShader_Custom.shader, remplace

    Shader “Standard (Specular setup)”


Shader "Standard (Specular setup), Set Alpha"


#include "UnityStandardCore.cginc" // There are 5 occurrences of this line, all must be replaced


#include "UnityStandardCore_Custom.cginc"
  • Make Unity use your own copy of : Render settings → Deferred → Custom → Pick your custom .shader

  • Replace

    Blend [_SrcBlend] [_DstBlend] // Line 16 in beta 21


Blend [_SrcBlend] [_DstBlend], Zero SrcAlpha


half4 res = UNITY_BRDF_PBS (baseColor, specColor, oneMinusReflectivity, oneMinusRoughness, normalWorld, -eyeVec, light, ind); // Line 66 in beta 21
return res;


half4 res = UNITY_BRDF_PBS (baseColor, specColor, oneMinusReflectivity, oneMinusRoughness, normalWorld, -eyeVec, light, ind);
res.a = gbuffer0.a;
return res;
  • You should now be able to change the reflectivity of the material by changing the diffuse color’s alpha; just make sure it uses your new custom standard shader.

A few notes

  • This may or may not interfere with occlusion, I’m not sure yet
  • I’m also not sure how it works with the transparent standard shader
  • In Unity 5 we now have access to the GBuffers, so Candela can skip doing their own pass and spare the fillrate (at least in deferred), so performance-wise, more modifications are needed.