# How can I create the same space as the depth cache?

**URL:** <https://forums.unrealengine.com/t/how-can-i-create-the-same-space-as-the-depth-cache/466660>\
**Category:** Rendering\
**Tags:** debug-trace, depth, unreal-engine, Rendering, CPP, question\
**Created:** [June 13, 2020, 2:56am UTC](https://forums.unrealengine.com/t/how-can-i-create-the-same-space-as-the-depth-cache/466660 "2020-06-13T02:56:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2ee04ade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2ee04ade](https://forums.unrealengine.com/u/anonymous_user_2ee04ade)\
**Post date:** [June 13, 2020, 2:56am UTC](https://forums.unrealengine.com/t/how-can-i-create-the-same-space-as-the-depth-cache/466660/1 "2020-06-13T02:56:11Z")

</div>

I would like to use the following code to create a depth cache space to read the depth cache from the GPU, which is only set to 100 \* 200

```
FTextureRenderTargetResource* DepthRenderTargetResource = nullptr;
	UTextureRenderTarget2D *Buffer_Depth_Float = NewObject<UTextureRenderTarget2D>(GetTransientPackage(), TEXT("DepthInspectorBufferDepthTarget"), RF_Standalone);
	Buffer_Depth_Float->AddToRoot();
	Buffer_Depth_Float->InitCustomFormat(100, 200, PF_DepthStencil, true);
	Buffer_Depth_Float->ClearColor = FLinearColor::Black;
	Buffer_Depth_Float->UpdateResourceImmediate(true);
	DepthRenderTargetResource = Buffer_Depth_Float->GameThread_GetRenderTargetResource();

```

But reported the following error, it seems that the PF\_DepthStencil format can not be created, and other formats can be created, but I checked the depth is the PF\_DepthStencil format

 ![304270-snipaste-2020-06-13-10-25-27.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/9/3/593d7c95baedd4adc2c64a2b7a4836395d1da0d9.png)

I also Debug debugging, before the UE start up has created a few PF\_DepthStencil format depth buffer space, but I failed to create their own, who knows how to create this depth buffer space?
