I’m trying to create a setup to do some computations on the gpu for performance reasons. I have a data Rendertarget which I want to update every frame to do shader computations on it. As a basic setup I just wanted to copy the existing color information of the previous frame and darken this image a bit. The expected outcome should be a colorful texture that slowly darkens with each frame. Eventually I would compute something more elaborate.
So, now for my rendersetup. I created a scene capture 2d and a rendertarget. The show flags for the scene capture ignore everything in my scene. All I’m rendering with the capture is a single blendable, a post process material. This material is my “computation shader”. It takes a data texture (which should be the texture from the previous frame), darkens it a bit and returns it as emissive. My plan was to set the RT as the target texture for my scene capture and also as a texture parameter input for my material. So essentially the RT gets darkened in the material, this darkened image gets drawn to the same RT, which, in the next frame, gets darkened again by the material.
To debug this system I added a button that would clear the RT with a full rect image. Once the button is released the computation would resume and gradually darken this image over time.
This test didn’t really work. I’m guessing because you can’t render onto the same texture that you’re trying to access. The image was displayed as expected, but the darkening effect didn’t work. The texture seemed to reset to its default color (black) as soon as the next frame started:
So I tried an alternate setup. This time with two rendertargets. RT1 would render onto RT2 and next frame they would alternate, RT2 would render onto RT1. This worked better, however, the image dramatically lost detail over time. It seemed as if the wrong mip map level was chosen each frame, resulting in the reduction of detail in the image:
(Mip maps are off both in the material as well as the rendertarget)
So, I’m asking if someone might know what could be the problem here. Maybe someone has done something similar?
Just for completeness sake, here is the material and blueprint I used: