# Error when reading DepthTexture of RenderTargetTexture

**URL:** <https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021>\
**Category:** Questions\
**Created:** [April 15, 2021, 1:53pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021 "2021-04-15T13:53:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luck\_Good](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/luck_good/32/8286_2.png) [@Luck\_Good](https://forum.babylonjs.com/u/Luck_Good)\
**Post date:** [April 15, 2021, 1:53pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/1 "2021-04-15T13:53:20Z")

</div>

[https://www.babylonjs-playground.com/#TV5FSK](https://www.babylonjs-playground.com/#TV5FSK)

[.WebGL-00004DFC00141C00] GL\_INVALID\_OPERATION: Mismatch between texture format and sampler type (signed/unsigned/float/shadow).

---

<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:** [April 15, 2021, 2:37pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/2 "2021-04-15T14:37:41Z")

</div>

Bringing up the latest from the thread on github:

In your case you are creating a comparison sampler or shadow sampler but use it as a depth sampler:

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#TV5FSK%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

[![@sebavan](https://avatars.githubusercontent.com/u/16655165?s=60&u=03f7b2a2237fe86236a9b0244a182af2c1032da0&v=4)](https://github.com/sebavan) [sebavan](https://github.com/sebavan) closed this [19 minutes ago](https://github.com/BabylonJS/Babylon.js/issues/10197#event-4599613270)

[![@GoodLuckIce](https://avatars.githubusercontent.com/u/9364696?s=88&u=2558892e055391e01aac1ea8f1dc882f16c5142e&v=4)](https://github.com/GoodLuckIce)

Author

### **[GoodLuckIce](https://github.com/GoodLuckIce)** commented [39 seconds ago](https://github.com/BabylonJS/Babylon.js/issues/10197#issuecomment-820474641)

thank you very much.  
But I actually want to get the correct depth value, but the obtained depth value is equal

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#TV5FSK%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

I need to use depth to determine the final result of the two rendering results, but the value of depth is equal, which is an error.

---

<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:** [April 15, 2021, 2:38pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/3 "2021-04-15T14:38:52Z")

</div>

@Luck_Good I am not sure to understand what you are trying to do here. Could you detail a bit more your use case ?

---

<div class="post-metadata">

**Author:** ![Luck\_Good](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/luck_good/32/8286_2.png) [@Luck\_Good](https://forum.babylonjs.com/u/Luck_Good)\
**Post date:** [April 15, 2021, 3:02pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/4 "2021-04-15T15:02:56Z")

</div>

@sebavan  
I have different types of models that require different rendering modes to render. Then I merge the final results together.  
such as:  
Use forge ([Forge | RCDB](https://forge-rcdb.autodesk.io/configurator?id=58cac141597e53832268b88e))  
The rendering mode of the engine renders the BIM model  
Use Cesium ([Cesium Demo](https://sandcastle.cesium.com/gallery/3D%20Tiles%20Photogrammetry.html))  
The rendering mode of the engine renders the 3dTiles model.  
Combine the final rendering results together.  
I am going to try to implement these rendering modes in babylonjs. Unfortunately, when I first started to implement this idea, I ran into the problem of ==\> depth acquisition error  
I really hope to get help to keep me going.

[https://www.babylonjs-playground.com/#TV5FSK#3](https://www.babylonjs-playground.com/#TV5FSK#3)

---

<div class="post-metadata">

**Author:** ![Luck\_Good](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/luck_good/32/8286_2.png) [@Luck\_Good](https://forum.babylonjs.com/u/Luck_Good)\
**Post date:** [April 15, 2021, 3:53pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/6 "2021-04-15T15:53:53Z")

</div>

Is this an engine bug? @sebavan

---

<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:** [April 15, 2021, 3:55pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/7 "2021-04-15T15:55:32Z")

</div>

It has only been 1 hour since your message, and I think it is mostly a setup error here.

You need to let time to the community to answer. I bet you ll have one by tomorrow.

---

<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:** [April 15, 2021, 6:26pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/8 "2021-04-15T18:26:01Z")

</div>

It looks like an angle issue as comparison samplers are fine: [https://www.babylonjs-playground.com/#TV5FSK#14](https://www.babylonjs-playground.com/#TV5FSK#14)

But not in read mode: [https://www.babylonjs-playground.com/#TV5FSK#11](https://www.babylonjs-playground.com/#TV5FSK#11)

You should try to create a chromium issue for it ?

---

<div class="post-metadata">

**Author:** ![Luck\_Good](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/luck_good/32/8286_2.png) [@Luck\_Good](https://forum.babylonjs.com/u/Luck_Good)\
**Post date:** [April 16, 2021, 2:04am UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/9 "2021-04-16T02:04:52Z")

</div>

> <https://github.com/BabylonJS/Babylon.js/issues/10205>
>
> https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettex…ture/20021
> 
> https://www.babylonjs-playground.com/#TV5FSK#11
> 
> I have the same error in edge chrome firefox browser

---

<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:** [April 16, 2021, 11:42am UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/10 "2021-04-16T11:42:14Z")

</div>

It is a setup issue in your PG as you are setting the depth texture in linear and only nearest is allowed.

We added a guard in engine for that.

---

<div class="post-metadata">

**Author:** ![Luck\_Good](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/luck_good/32/8286_2.png) [@Luck\_Good](https://forum.babylonjs.com/u/Luck_Good)\
**Post date:** [April 16, 2021, 12:21pm UTC](https://forum.babylonjs.com/t/error-when-reading-depthtexture-of-rendertargettexture/20021/11 "2021-04-16T12:21:12Z")

</div>

Thank you very much, I have learned the correct setting method

[https://www.babylonjs-playground.com/#TV5FSK#16](https://www.babylonjs-playground.com/#TV5FSK#16)
