Shader from threejs to babylonjs

Hello i am trying to replicate a shader from threejs
https://github.com/pmndrs/drei/blob/59d679c5f204b85a959cf06f3e2e16b467158152/src/materials/MeshRefractionMaterial.tsx

my question is if it’s possible and if there’s an example or an advice to refer to

Hello! Both Three and Babylon shaders are written in the same language, GLSL, so it should be fairly straightforward. Having a quick look at it, the most involved part seems to be the BVH structure, as you’d have to port that to Babylon too.

I am trying to convert it like this

but I am having a lot of errors in the console and I do not understand what is causing the errors because the messages are not very user-friendly

if you can give me a hint how i can debug it
and one more question Do uniforms defer from engine to engine?

The uniforms are different from engine to engine. They might have the same name for time to time, but in general they are not the same. This is the list of built in uniforms:

Otherwise, you will need to define the uniforms you need and set them. you can read about it here - Shader Material | Babylon.js Documentation along with examples.

2 Likes