Getting custom texture data per model (uv projection) in postprocess

For an effect my art director wants, I need access to a custom texture per model inside a postprocess material. Essentially adding a SceneTexture channel. Imagine something like a textured shadow (use a cell-shader like construct to identify shadows, add a map into those areas), but using a map uv-mapped onto the surface that can differ per model, instead of in screen space. This isn’t the effect we’re after, but another one which would require a solution to the same problem.

I’m aware this can be done via a custom shading model, but as best I can tell making one can only be done by rebuilding the engine from source, something which can’t be done for this project due to logistical reasons. We’re a student project, and need to be able to run on our school computers, and can’t handle distributing and updating an engine version to our large team.

I’ve also developed a workaround, where I pack the data into a range + or - x from .5, then send it into the spec channel, then read spec out of scene texture into the postprocess material and unpack it back to 0-1. This is functional, but has two main drawbacks, depending on the value of x. At higher values of x, it begins to be noticeable on the specularity of the model. At lower values of x, the specularity appears normal, but the bit depth is low due to the compression process. This also only gets us a single channel.

A third potential lead is to find a way to reenable the AO texture channel, but configure the settings so it has zero effect, then use that scene texture channel. We haven’t looked into this much yet so I’m not sure if it’s possible.

So with the context out of the way, the question is: Is there a better way of achieving the same effect, without the drawbacks of the spec method, or rebuilding the engine from source? It would also be great to get multiple channels. Thanks!

To enable the AO channel, you must disable static lighting in the project settings. Not sure how you’d be able to negate the AO contribution without engine modifications. A render target may be able to achieve what you are trying to do - the passes in the gbuffer essentially are just render targets themselves. The custom depth & stencil feature allows you to render objects to a special pass but it isn’t quite what you’re looking for. Objects can be tagged with a bit value in the stencil which can be read in the scene sample to get a per object effect, but it won’t have access to UVs or anything. It’s mostly used for masking. You can also project world aligned textures onto objects using a depth sample. Combined with the per object masking I mentioned you could get interesting results on static objects.

Did you ever figure something out for this? I’m dealing with having to pass data from my object materials to post processing material, not having a lot of luck

What kind of data specifically?

OP is talking abut UV data, but the broader idea is to be able to pass anything from an object material graph into the post processing materials, like how you can get the unlit albedo texture.

The main issue is that there is quite limited space in the gbuffer. Rendering that data out requires extra passes that there simply is little room for. So usually any time you want to do something like this it’s going to mean repurposing an otherwise unused pass.
Anisotropy and Material Ambient Occlusion are often the first buffers to be repurposed.
I could be mistaken, but off the top of my head AO is grayscale and Anisotropy is RG, so that’s a total of 3 channels of data that can be requisitioned fairly freely.
It would require modification to the base engine’s shaders to disable these outputs from doing their normal thing - because if you’re passing some arbitrary data through the anisotropic buffer for example, you don’t actually want it to use that data to apply expensive and undesired anisotropy to your materials.