Use RenderTexture as ShaderResource in DX11 native plug-in

Hi all,

I’d like to render the content of a RenderTexture (it’s not the main rendertarget but an orthographic projection of a part of the scene) in a separate window of a native DX11 plug-in I’m writing. Currently, I render the scene into a RenderTexture and use the CPU-based Texture2D.ReadPixels operation to copy the content into a Texture2D. I then share the pointer to that Texture2D with my native DX11 plug-in, which displays it in a quad.

I couldn’t find a way to create a ShaderResourceReview directly from the pointer of RenderTexture or to copy the content of RenderTexture to a Texture2D or other GPU-based buffers in a compute buffer. Texture2D.ReadPixels is hurting my framerate…

Does anyone have an idea? Or know any other way to display Unity-rendered off-screen content in a plug-in’s window?

Thanks guys! Your help is very much appreciated! :slight_smile:

David

I’m going to assume this is more than just a material in Unity (not sure what you mean by native DX11 plugin). If it does happen to just be a material in Unity, you CAN assign a RenderTexture directly to the material (and thus the shader). No need to change to a Texture2D

That being said, RenderTexture is derived from Texture. It’s a shot in the dark, but can you cast the RenderTexture to a Texture, then re-cast that to a Texture2D?