# Glass Material PBR Effect

**URL:** <https://forum.babylonjs.com/t/glass-material-pbr-effect/46335>\
**Category:** Questions\
**Created:** [December 11, 2023, 2:07pm UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335 "2023-12-11T14:07:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karim\_Salam](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karim_salam/32/30201_2.png) [@Karim\_Salam](https://forum.babylonjs.com/u/Karim_Salam)\
**Post date:** [December 11, 2023, 2:07pm UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335/1 "2023-12-11T14:07:29Z")

</div>

Hello Guys,

I have a model that contains a glass material, i tried to achieve the glass effect by importing the model to sandbox and enabling refraction in the subsurface and tweaking a little bit of settings then exporting it, the effect is achieved but the file size is jumping from 1.7 MB to 111 MB, and to 5MB after compressing, the thing is i noticed that sandbox is adding a “opaqueSceneTexture” which is the reason of achieving this effect, i need to know how to generate that through the scene please, i attached the result that i want to achieve through the scene code and not sandbox

 ![screenshot](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/a/6a986b824237ec93376667de44ef98983b46058f.jpeg)

Best Regards.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 11, 2023, 9:22pm UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335/2 "2023-12-11T21:22:16Z")

</div>

What format are you using ? as I think the easiest is to add those extra info in the file manually.

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [December 12, 2023, 9:29am UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335/3 "2023-12-12T09:29:25Z")

</div>

I agree with the above and would also recom to simply create and replace mat in BJS.

---

<div class="post-metadata">

**Author:** ![Karim\_Salam](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karim_salam/32/30201_2.png) [@Karim\_Salam](https://forum.babylonjs.com/u/Karim_Salam)\
**Post date:** [December 12, 2023, 10:52am UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335/4 "2023-12-12T10:52:55Z")

</div>

Thank you for the replies, the model format is .glb, so what do you mean by adding those info in the file, through 3ds max for example ?

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [December 12, 2023, 10:58am UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335/5 "2023-12-12T10:58:11Z")

</div>

> [@Karim\_Salam](#):
>
> what do you mean by adding those info in the file

I think @sebavan (and then, me 😉) are simply suggesting to create a new material in BJS and assign it to the mesh(es). Else, change some parameters on the original material (through script) before exporting. Point is, for whatever you have been doing through the sandbox (and next likely click on export for scene or mesh), you must have made alterations to the entire scene or model (at least, I assume so giving the numbers you are sharing).

---

<div class="post-metadata">

**Author:** ![qq2315137135](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/qq2315137135/32/32219_2.png) [@qq2315137135](https://forum.babylonjs.com/u/qq2315137135)\
**Post date:** [December 13, 2023, 7:30am UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335/6 "2023-12-13T07:30:46Z")

</div>

“opaqueSceneTexture” is added by the gltf extension KHR\_materials\_transmission.  
It is fully automatic, just import the glb file with the glass material, no extra coding is needed.

If you want to use this feature without importing a glb file, you need to use the TransmissionHelper.

However, it is located in the source code and is not available to users.

> <https://github.com/BabylonJS/Babylon.js/blob/6bfb7d78f2d99e8c1e9eb4d1102774d1f16cce80/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts#L66-L120>

---

<div class="post-metadata">

**Author:** ![Karim\_Salam](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karim_salam/32/30201_2.png) [@Karim\_Salam](https://forum.babylonjs.com/u/Karim_Salam)\
**Post date:** [December 13, 2023, 2:09pm UTC](https://forum.babylonjs.com/t/glass-material-pbr-effect/46335/7 "2023-12-13T14:09:55Z")

</div>

Thank you for the reply i will try that 😃
