4.2 Beta and subsurface/refraction

We’re attempting to upgrade from 4.1.alpha to 4.2.beta and we’re noticing a change in how refractions are working. I notice there’s a new subsurface configuration, but is there any documentation on what changed specifically around refraction and setting up the refraction parameters? We see strange blocking/pixelization and colors look different. Is there a playground with refraction that uses this new object?


pinging @sebavan and @Evgeni_Popov

1 Like

Ohhhh it should be compatible :frowning: could you share a playground or repro ???

1 Like

It’s hard to set up as a Playground, but I can show you some screenshots:

The model in blue is refracting, but it’s also allowing some translucency. In the white version (my local version) the transparency appears to be broken so it’s refracting but not transparently.

Does that make sense?

can you check that material (the one no more transparent) is correctly set to be non opaque?

It is. It’s set up with the following parameters:

  1. Albedo texture is set to hasAlpha = true
  2. Material is set to alpha blend and test and combine
  3. Material has translucency enabled and link refraction with translucency
  4. Material has alphaFromAlbedo = true

Using 4.1.alpha with the same settings produces the blue result, while 4.2 products the white result. Any ideas? I’m sure it’s a single setting somewhere that’s throwing it off.

ok i let @sebavan answer then but ideally a repro in the PG would be the best way to get a fast answer

Or a live link on both cases, that way we could use Spector to spot the differences.

Is there a way to specify Babylon version in the Playground?

Yes, you have an icon in the top right corner:


The icon on the left.

Great. I may be able to set up an example using just code.

could you try changing the refractionIndex by 1 / refractionIndex ? i think we fixed an issue about this where the index of refraction was setup wrongly before ?

1 Like

Ok, I’m able to repro using this Playground:


Using 4.1 I can see the blue sphere refracting through the green sphere. Using 4.2, the refraction seems really oversized and distorted. Hopefully, I’m not crazy because this has been really confusing.


First image is 4.2, and you can’t see the blue, second image is 4.1 and you can see it right behind.

I have a different output with 4.2:

We can see the blue sphere but more deformed. That’s because there’s a bug with the material cloning, which will be fixed by:

Waiting for the fix, not cloning the materials and recreating them from scratch should correct your problems.

Another way to correct the problem before the fix is to set volumeIndexOfRefraction with the same value than indexOfRefraction.

1 Like

You are the king @Evgeni_Popov

This seems to fix the issue in the playground. I’ll try our main code base to see if there is still a problem. Thanks for looking into it!


1 Like

There’s still one difference, which is that in the older version we get specular highlights on a refracted surface while in 4.2.beta, to get a similar look I have to enable clearcoat. Any ideas what that’s about?