better principled refraction (adds thin glass plus works fine in eevee)

Issue #104 resolved
Alessandro Padovani created an issue

We currently have two refraction options for the principled shader that are principled and guess, where the difference is that guess also handles thin glass while principled doesn't. But guess doesn't work fine with eevee since it uses the metallic channel for thin glass reflections that gets different results in cycles and eevee.

Now the following method uses clearcoat instead of metallic. It works fine both in cycles and eevee with similar results. The reason why I didn't use clearcoat before is because it seems weak since the slider gets 1 as max value. But we can input greater values in the numeric field to get stronger reflections. Also I was focusing on cycles where metallic works fine. I'm starting now to work for eevee too since blender 2.82 seems good enough.

With this method we don't need guess anymore so we can keep a single principled option for refraction. For example this gets the iray reflections for the G8F eyes in eevee that wasn't possible before.

# principled glass equations (iray refraction weight = 1)

principled transmission = 1
principled ior = iray refraction index

# if share glossy input is on then volume and surface roughness are the same
if share glossy input is on
  principled roughness = iray glossy roughness

# if share glossy input is off then surface and volume roughness are different
# but the principled shader only have one roughness
if share glossy input is off
  principled roughness = iray refraction roughness

# if thin walled is on then there's no volume
# and we use the clearcoat channel for reflections
if thin walled is on
  principled ior = 1
  principled roughness = 0
  principled clearcoat = (iray refraction index - 1) * 10 * iray glossy layered weight
  principled clearcoat roughness = 0

# principled glass color (iray refraction weight = 1)

if share glossy input is on
  principled base color = iray glossy color
  principled specular tint = 1

if share glossy input is off
  principled base color = iray refraction color
  principled specular tint = 0

if thin walled is off and iray transmitted color <> [white,black] and iray transmitted distance > 0
  principled base color = principled base color * iray transmitted color

Please note that there are limitations. First the principled shader can't do colored reflections. Second for thin glass (ior 1) the principled shader can't do roughness since it's intended for volume (ior > 1). Also eevee has limitations over cycles since the refraction is computed fine only for the first ray bounce. Then the roughness follows because it's volumetric. Other than that it works fine enough.

https://docs.blender.org/manual/en/latest/render/eevee/limitations.html

Below some examples, first iray then cycles then eevee. Scene file included.

Also below the G8F eyes first iray then cycles then eevee. Of course cycles here uses the fixed principled and sss options for materials since the volumetric skin doesn't work for eevee. So the cycles quality in "reduced" on purpose to better compare with eevee.

Comments (3)

  1. Alessandro Padovani reporter

    As for commit 14e63b7, it seems if there's no transmap then it doesn’t set the blend mode and refraction options in the material settings, thus the eevee rendering looks opaque. Below an example with the G8F eyemoisture.

    If there’s no transmap and the alpha channel > 0.5 alpha clip may be better because it doesn’t use visible dithering, though it could be more or less transparent than intended. Then alpha hash is required for transmapped materials. While alpha blend is to be avoided because it causes artifacts with multiple transparency layers as in daz hair.

    Screen space refraction is always needed for refractive materials (transmission = 1).

  2. Log in to comment