How to import models with advanced refraction?

Hi guys,

Recently there was a release of glTF Viewer 2.0 and it supports advanced refraction which is definitely cool.

But there’s an issue.
When I export my model in .fbx format, the advanced refraction doesn’t work neither in the editor nor in the viewer.
When I export my model in glTF 2.0 (.glb/.gltf) format, I can view its advanced refraction in the viewer, but I can’t place the model on the scene in the editor.

Can I somehow turn on advanced refraction on the model on the scene to use it in the game?

At the moment, the engine side refraction feature has been released, and it’s available in the engine / editor projects, where appropriate material properties are set up using scripts.

Soon, we should be releasing those material properties exposed in the material inspector in the Editor. At that point, you should be able to set those from the inspector, and see the effect in the editor / launched project.

But as I said, even if you do not see the effect in the Editor yet, you can enable those using script on the material, and they would work in the game.

Note that additionally, on top of material properties, you need to enable this as well, so that the scene buffer is captured to be used by the refraction shader:

camera.requestSceneColorMap(true);

1 Like

Hi Martin,

Sorry, but how exactly to enable those properties via script?

Here is the link to the test project: PlayCanvas | HTML5 Game Engine

You mostly likely are after the KHR_materials_volume - see details here

and so the parameters on material would be these

especially the

material.blendType = BLEND_NORMAL;
material.useDynamicRefraction = true;

@Gustav_Sterbrant would know the details if you dont get this working.

3 Likes

@Taras Hello!

What @mvaligursky says is correct, enabling the useDynamicRefraction on the material will trigger the shader to compile with dynamic refractions, meaning the shader will use the scene as refraction data. It also does a bunch of other things, such as attenuation, so be sure to provide the material with the appropriate attenuation and thickness textures/parameters if you have them.

Please don’t hesitate to come back with any questions regarding how to use this material. It’s not been exposed in the editor yet so it can be a bit tricky to play around with.

Thanks,
Gustav

4 Likes

(post deleted by author)

I wonder is there any way to increase scene colormap resolution? To make the refracted image sharper/less pixelated? And what is its default resolution?
image