# \#shader-material

**URL:** https://forum.babylonjs.com/tag/shader-material/357.md

[Latest](https://forum.babylonjs.com/latest.md) · [Categories](https://forum.babylonjs.com/categories.md) · [Tags](https://forum.babylonjs.com/tags.md)

---

## [WebGPU non-compatibility mode: thinInstanceSetBuffer on a WGSL ShaderMaterial mesh leaves a stale render bundle ("used in submit while destroyed")](https://forum.babylonjs.com/t/webgpu-non-compatibility-mode-thininstancesetbuffer-on-a-wgsl-shadermaterial-mesh-leaves-a-stale-render-bundle-used-in-submit-while-destroyed/64385)

<div class="topic-metadata">

**Author:** [@tapanij](https://forum.babylonjs.com/u/tapanij)\
**Replies:** 1\
**Last updated:** [October 25, 2026, 5:49pm UTC](https://forum.babylonjs.com/t/webgpu-non-compatibility-mode-thininstancesetbuffer-on-a-wgsl-shadermaterial-mesh-leaves-a-stale-render-bundle-used-in-submit-while-destroyed/64385 "2026-10-25T17:49:32Z")

</div>

With engine.compatibilityMode = false, replacing the thin-instance buffers of a mesh that uses a WGSL ShaderMaterial after it has been drawn leaves its cached render bundle pointing at the old buffer. The old buffer is d…

---

## [Emission material not showing up or moving?](https://forum.babylonjs.com/t/emission-material-not-showing-up-or-moving/63454)

<div class="topic-metadata">

**Author:** [@c4cc](https://forum.babylonjs.com/u/c4cc)\
**Replies:** 1\
**Last updated:** [May 13, 2026, 7:34pm UTC](https://forum.babylonjs.com/t/emission-material-not-showing-up-or-moving/63454 "2026-05-13T19:34:09Z")

</div>

In Blender, the emission on the circuits flows as intended In Babylon.js, that emission for the circuits does not even show, much less flow as intended

---

## [Function included in serialized result after enableEdgesRendering](https://forum.babylonjs.com/t/function-included-in-serialized-result-after-enableedgesrendering/62575)

<div class="topic-metadata">

**Author:** [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Replies:** 4\
**Last updated:** [March 3, 2026, 6:20pm UTC](https://forum.babylonjs.com/t/function-included-in-serialized-result-after-enableedgesrendering/62575 "2026-03-03T18:20:24Z")

</div>

OS: Win10 Engine: WebGL2 Browser: any Version: 8.52.1 Steps to reproduce: Open the playground: Babylon.js Playground Check console for errors Expected: No errors Actual: s.materials\[0\].options.extraInitializati…

---

## [Instancing with shaderMaterial and orthographic bug?](https://forum.babylonjs.com/t/instancing-with-shadermaterial-and-orthographic-bug/59960)

<div class="topic-metadata">

**Author:** [@Wigen](https://forum.babylonjs.com/u/Wigen)\
**Replies:** 6\
**Last updated:** [August 15, 2025, 5:32pm UTC](https://forum.babylonjs.com/t/instancing-with-shadermaterial-and-orthographic-bug/59960 "2025-08-15T17:32:03Z")

</div>

:edit: question is now around how instances and shaderMaterial are not working like standardMaterial’s z order when using a orthographic camera. Instancing with shaderMaterial and orthographic bug? - #5 by Wigen My que…

---

## [Fresnel Effect on PBRMaterial Without Replacing Original Material](https://forum.babylonjs.com/t/fresnel-effect-on-pbrmaterial-without-replacing-original-material/57682)

<div class="topic-metadata">

**Author:** [@DarkHorse](https://forum.babylonjs.com/u/DarkHorse)\
**Replies:** 12\
**Last updated:** [April 11, 2025, 12:43am UTC](https://forum.babylonjs.com/t/fresnel-effect-on-pbrmaterial-without-replacing-original-material/57682 "2025-04-11T00:43:57Z")

</div>

Hey everyone! I’m working on a two-tone colored car model and trying to add a Fresnel effect to give it a more dynamic look. This is the car before applying the effect: This is after i have applied that effect. …

---

## [Summary of objects in WebGPU ShaderMaterial and Babylon-specific WGSL](https://forum.babylonjs.com/t/summary-of-objects-in-webgpu-shadermaterial-and-babylon-specific-wgsl/57493)

<div class="topic-metadata">

**Author:** [@HiGreg](https://forum.babylonjs.com/u/HiGreg)\
**Replies:** 2\
**Last updated:** [April 1, 2025, 6:20am UTC](https://forum.babylonjs.com/t/summary-of-objects-in-webgpu-shadermaterial-and-babylon-specific-wgsl/57493 "2025-04-01T06:20:25Z")

</div>

Edited to correct my errors based on @Evgeni\_Popov’s reply I had a rough time figuring out how to declare Babylon objects and use them within Babylon’s slightly-modified WGSL shader language. This comes from experimenta…

---

## [StorageTexture writable from WebGPU Vertex Shader?](https://forum.babylonjs.com/t/storagetexture-writable-from-webgpu-vertex-shader/57499)

<div class="topic-metadata">

**Author:** [@HiGreg](https://forum.babylonjs.com/u/HiGreg)\
**Replies:** 3\
**Last updated:** [March 31, 2025, 8:15am UTC](https://forum.babylonjs.com/t/storagetexture-writable-from-webgpu-vertex-shader/57499 "2025-03-31T08:15:44Z")

</div>

Error in console: How do I add a StorageTexture that I write from WebGPU Vertex Shader. I get Storage texture binding with StorageTextureAccess::WriteOnly is used with a visibility (ShaderStage::Vertex) that contain…

---

## [With WebGPU, material.setFloat() in onBeforeRender causes mesh to disappear](https://forum.babylonjs.com/t/with-webgpu-material-setfloat-in-onbeforerender-causes-mesh-to-disappear/57467)

<div class="topic-metadata">

**Author:** [@HiGreg](https://forum.babylonjs.com/u/HiGreg)\
**Replies:** 3\
**Last updated:** [March 29, 2025, 6:08am UTC](https://forum.babylonjs.com/t/with-webgpu-material-setfloat-in-onbeforerender-causes-mesh-to-disappear/57467 "2025-03-29T06:08:50Z")

</div>

When using WebGPU, material.setFloat() in scene.onBeforeRenderObservable causes mesh to disappear. The fix is to add a delay of 1-2 seconds after mesh.onReady triggers, before adding the observer. I don’t have a simple…

---

## [Parallax ray marching, smol PG](https://forum.babylonjs.com/t/parallax-ray-marching-smol-pg/55584)

<div class="topic-metadata">

**Author:** [@Heaust-ops](https://forum.babylonjs.com/u/Heaust-ops)\
**Replies:** 0\
**Last updated:** [December 26, 2024, 10:27pm UTC](https://forum.babylonjs.com/t/parallax-ray-marching-smol-pg/55584 "2024-12-26T22:27:12Z")

</div>

So I saw this youtuber making a voxel game engine, and the tech he used in the early stages (he later just switched to ray tracing), is a thing I found really cool and unique. The idea is to make a large …

---

## [May I ask if there is a faster way for ShaderMaterial to obtain the corresponding data during the data exchange process?](https://forum.babylonjs.com/t/may-i-ask-if-there-is-a-faster-way-for-shadermaterial-to-obtain-the-corresponding-data-during-the-data-exchange-process/55165)

<div class="topic-metadata">

**Author:** [@zertaul](https://forum.babylonjs.com/u/zertaul)\
**Replies:** 2\
**Last updated:** [December 17, 2024, 1:00am UTC](https://forum.babylonjs.com/t/may-i-ask-if-there-is-a-faster-way-for-shadermaterial-to-obtain-the-corresponding-data-during-the-data-exchange-process/55165 "2024-12-17T01:00:16Z")

</div>

As shown in the question, when I use shaderMaterial to create custom materials, if I need to store data, I can find specialized data storage methods such as setfloat, setVector3, etc. in the API. However, obtaining the c…

---

## [Issue Rendering ShaderMaterial Snapshot Using RenderTargetTexture in Babylon.js](https://forum.babylonjs.com/t/issue-rendering-shadermaterial-snapshot-using-rendertargettexture-in-babylon-js/53628)

<div class="topic-metadata">

**Author:** [@webgrid](https://forum.babylonjs.com/u/webgrid)\
**Replies:** 3\
**Last updated:** [September 23, 2024, 8:27am UTC](https://forum.babylonjs.com/t/issue-rendering-shadermaterial-snapshot-using-rendertargettexture-in-babylon-js/53628 "2024-09-23T08:27:00Z")

</div>

Hi, I create awesome clouds for my game on a plane using ShaderMaterial. However, it’s resource-intensive, so I would like to take a snapshot of the Babylon plane with ShaderMaterial using RenderTargetTexture and apply…

---

## [How do I write ShaderMaterial depth to DepthRenderer (infinite far plane)](https://forum.babylonjs.com/t/how-do-i-write-shadermaterial-depth-to-depthrenderer-infinite-far-plane/53461)

<div class="topic-metadata">

**Author:** [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Replies:** 3\
**Last updated:** [September 17, 2024, 7:43am UTC](https://forum.babylonjs.com/t/how-do-i-write-shadermaterial-depth-to-depthrenderer-infinite-far-plane/53461 "2024-09-17T07:43:54Z")

</div>

Hello everyone! I am having issues writing to a DepthRenderer with a ShaderMaterial when the far plane is at infinity (maxZ=0) This is a follow-up to a previous question that did not use the far plane at infinity: How …

---

## [Getting depthSampler using custom shaderMaterials and custom postProcess](https://forum.babylonjs.com/t/getting-depthsampler-using-custom-shadermaterials-and-custom-postprocess/51911)

<div class="topic-metadata">

**Author:** [@Gimli](https://forum.babylonjs.com/u/Gimli)\
**Replies:** 9\
**Last updated:** [July 10, 2024, 8:16am UTC](https://forum.babylonjs.com/t/getting-depthsampler-using-custom-shadermaterials-and-custom-postprocess/51911 "2024-07-10T08:16:27Z")

</div>

Hello everyone, I currently work on the recreation of the fluid renderer since I work with a lot of particle systems and change the position of the particles within the vertexShader. Therefore, I need to write my own sh…

---

## [Ripple ShaderMaterial](https://forum.babylonjs.com/t/ripple-shadermaterial/51963)

<div class="topic-metadata">

**Author:** [@Impurity](https://forum.babylonjs.com/u/Impurity)\
**Replies:** 3\
**Last updated:** [July 9, 2024, 8:37pm UTC](https://forum.babylonjs.com/t/ripple-shadermaterial/51963 "2024-07-09T20:37:09Z")

</div>

I’m trying to replicate this ripple shader on shadertoy in this playground, but for some reason I am unable to. Does anyone see where my problem is? The explanation logic of what I was trying to do is also found here: A…

---

## [Cannot read texture\_storage\_2d in WebGPU ShaderMaterial](https://forum.babylonjs.com/t/cannot-read-texture-storage-2d-in-webgpu-shadermaterial/50008)

<div class="topic-metadata">

**Author:** [@Eric.J](https://forum.babylonjs.com/u/Eric.J)\
**Replies:** 2\
**Last updated:** [April 25, 2024, 3:59pm UTC](https://forum.babylonjs.com/t/cannot-read-texture-storage-2d-in-webgpu-shadermaterial/50008 "2024-04-25T15:59:18Z")

</div>

Is it not allowed to set the “storageTexture : texture\_storage\_2d” to “read\_write” in the WebGPU ShaderMaterial. When I change it to “read\_write”, the console shows the warnning message: “The layout’s binding access (Sto…

---

## [Help with shader material that projects a screen-sized texture on a quad without distortion?](https://forum.babylonjs.com/t/help-with-shader-material-that-projects-a-screen-sized-texture-on-a-quad-without-distortion/49550)

<div class="topic-metadata">

**Author:** [@christian](https://forum.babylonjs.com/u/christian)\
**Replies:** 1\
**Last updated:** [April 11, 2024, 7:49am UTC](https://forum.babylonjs.com/t/help-with-shader-material-that-projects-a-screen-sized-texture-on-a-quad-without-distortion/49550 "2024-04-11T07:49:08Z")

</div>

Hi, I’m trying to write a shader material that projects a screen-sized texture onto a quad. I drew an example of what I mean below. There is a texture that takes up the whole screen, but I only want the portion of the sc…

---

## [WebGPU error add sampler uniform custom Shader Material using GLSL](https://forum.babylonjs.com/t/webgpu-error-add-sampler-uniform-custom-shader-material-using-glsl/49379)

<div class="topic-metadata">

**Author:** [@JoseAlcaraz](https://forum.babylonjs.com/u/JoseAlcaraz)\
**Replies:** 2\
**Last updated:** [April 5, 2024, 4:33pm UTC](https://forum.babylonjs.com/t/webgpu-error-add-sampler-uniform-custom-shader-material-using-glsl/49379 "2024-04-05T16:33:23Z")

</div>

Hello BJS world. I’m getting an error when trying to define a sampler2D variable texture1 inside a fragment shader. It seems to work with WebGL, but when I switch to WebGPU I get the error and nothing renders. PG here. …

---

## [Custom highlightLayer when the sign of the scaling vector is different between an instance and the root mesh](https://forum.babylonjs.com/t/custom-highlightlayer-when-the-sign-of-the-scaling-vector-is-different-between-an-instance-and-the-root-mesh/46939)

<div class="topic-metadata">

**Author:** [@KevinWu](https://forum.babylonjs.com/u/KevinWu)\
**Replies:** 3\
**Last updated:** [January 4, 2024, 12:11pm UTC](https://forum.babylonjs.com/t/custom-highlightlayer-when-the-sign-of-the-scaling-vector-is-different-between-an-instance-and-the-root-mesh/46939 "2024-01-04T12:11:41Z")

</div>

I use instance buffer and custom material to distinguish between instance mesh renderings with the same source mesh. Everything was going well until I had the following situation: he sign of the scaling vector is differe…

---

## [ShaderMaterial with no erros but mesh is transparent](https://forum.babylonjs.com/t/shadermaterial-with-no-erros-but-mesh-is-transparent/45904)

<div class="topic-metadata">

**Author:** [@jgabriel2302](https://forum.babylonjs.com/u/jgabriel2302)\
**Replies:** 2\
**Last updated:** [November 24, 2023, 5:58pm UTC](https://forum.babylonjs.com/t/shadermaterial-with-no-erros-but-mesh-is-transparent/45904 "2023-11-24T17:58:34Z")

</div>

:exclamation: :person\_raising\_hand: Guys, can anyone help me, please? :person\_raising\_hand: :exclamation: I’m trying to implement this shader that was generated in NME, but it doesn’t work. Neither using the exported…

---

## [How to properly set up a Vite project when using custom shaders and ShaderMaterial](https://forum.babylonjs.com/t/how-to-properly-set-up-a-vite-project-when-using-custom-shaders-and-shadermaterial/44193)

<div class="topic-metadata">

**Author:** [@johannesugb](https://forum.babylonjs.com/u/johannesugb)\
**Replies:** 8\
**Last updated:** [September 17, 2023, 8:45am UTC](https://forum.babylonjs.com/t/how-to-properly-set-up-a-vite-project-when-using-custom-shaders-and-shadermaterial/44193 "2023-09-17T08:45:46Z")

</div>

Disclaimer: First of all, my whole JavaScript framework/setup/build system/etc. knowledge is very limited, so it can be very likely that I am missing something fundamental or basic. Question: I have set up a Vite-based…

---

## [Cannot use \`uint\` uniforms in shaderMaterial](https://forum.babylonjs.com/t/cannot-use-uint-uniforms-in-shadermaterial/43998)

<div class="topic-metadata">

**Author:** [@Shubidumdu](https://forum.babylonjs.com/u/Shubidumdu)\
**Replies:** 2\
**Last updated:** [September 11, 2023, 12:41pm UTC](https://forum.babylonjs.com/t/cannot-use-uint-uniforms-in-shadermaterial/43998 "2023-09-11T12:41:08Z")

</div>

Hi, this is my first time writing to this forum to ask a question. :slight\_smile: I’ve been trying a few things with ShaderMaterial, and the only time I run into the error is when I try to use a uniform of type uint by s…

---

## [View matrix not passed to shader when using ShaderMaterial](https://forum.babylonjs.com/t/view-matrix-not-passed-to-shader-when-using-shadermaterial/42126)

<div class="topic-metadata">

**Author:** [@johannesugb](https://forum.babylonjs.com/u/johannesugb)\
**Replies:** 1\
**Last updated:** [July 4, 2023, 9:12am UTC](https://forum.babylonjs.com/t/view-matrix-not-passed-to-shader-when-using-shadermaterial/42126 "2023-07-04T09:12:29Z")

</div>

I’m writing custom shaders and trying to get the matrices into shaders. It works just fine for worldViewProjection but not for view. As far as I can tell, all the values of view are just 0.0. But according to the Buildi…

---

## [\[SOLVED\] Shader Material with WebGPU](https://forum.babylonjs.com/t/solved-shader-material-with-webgpu/42060)

<div class="topic-metadata">

**Author:** [@Hersir](https://forum.babylonjs.com/u/Hersir)\
**Replies:** 6\
**Last updated:** [June 30, 2023, 10:47am UTC](https://forum.babylonjs.com/t/solved-shader-material-with-webgpu/42060 "2023-06-30T10:47:02Z")

</div>

Hi, noticed issue with Shader Material on WebGPU renderer PG here. Basically setting Array2 or Array3 creates error: uniformBuffer.ts:768 Uncaught TypeError: Cannot read properties of undefined (reading 'strideSize') …
