How to manipulate a render target with texture coordinates?

Hi everyone,

I’m hoping to get some insight on a problem i’m having.

What I’m trying to do:
I’m trying to bake out rendering information from a camera view to a models uv space.

I used Ryan Brucks baking to render targets as a good starting point. I’m basically, capturing the scene to a render target. Then I change out the material and bake out the Texture Coordinates of the model to a second render target., and then switch the material back to normal.

Then, my problem is when I try to feed the UV coordinates Render Target into the Scene Render Target, it comes out nothing like I imagined. All I want to do is take the pixel and move it to its represented Texture Coordinate. So basically, I should see the scene elements on in the UV layout like the fire, smoke, ect…

I’ve been working on this for awhile now and I’m stuck trying to get the transform correct and I was hoping someone else could give a suggestion on what i’m doing wrong. Thanks!

Interesting enough, If I feed the same UV rendered Texture Coordinates into the UV’d placed texture, it will transpose it to the correct location. It’s actually doing the opposite of what I need it to do.

Here is what I’m getting for the result which is basically moving the uv locations opposite of the desired result. I’ve been trying all kinds of math operations to inverse whats happening, but I’m not having any success.

Alright so I did get the shader working:

Basically, you’re not able to transpose pixel information from one location to another location in UE4 a “Scatter” operation, so I had to create a custom HLSL shader to “Gather” all of the information which required scanning the whole texture. Everything works great until you crank up the resolution to 2K and it becomes too heavy to run at realtime.

Next step is to try writing a custom c++ buffer to avoid all the of the costly scanning code. Thanks to @RyanB for the helpful forum posts and shaderbits blog which helped me figure everything out in writing custom HLSL :slight_smile:

1 Like

Could you share the solution? I have similar problems. I need to render the UV coordinates of any object in the scene, I believe something very close to what you achieved. This material still doesn’t generate the coordinates correctly, something is missing…Thank you very much.