Per-object grab pass?

Hi there,

I’ve read that GrabPass will prompt unity to capture everything rendered into a texture every time an object uses it. This seems like a really bad design decision. Is there a way to have a similar effect but where the grab pass is only performed -once- and then every object in the scene shares that same grabbed texture?

This is another reason I hope that in Unity 4, they open up their rendering pipeline to programmers so we know exactly what its doing and can control what it does. Another example - any material which uses a grab pass causes a camera with it’s clear flags set to “depth only” to blot out all cameras underneath it, rendering trails instead. If we could see where this is happening and modify the pipeline, we’d be able to fix this ourselves.

I’m not entirely sure what you’re asking for… you want each object to have a grab pass of the entire screen, that’s taken as they’re rendered, but for them all to share the same grabbed texture… as they’re rendered?

What effect are you trying to do, exactly? It might be better done as an image effect on the final rendered image.

If you read the very next bit of the manual, it explains the syntax for sharing grabs.

For those wondering:
GrabPass { “TextureName” } will grab screen contents into a texture, but will only do that once per frame for the first object that uses the given texture name. The texture can be accessed in further passes by the given texture name. This is a more performant way when you have multiple objects using grab pass in the scene.

What is the low-level operation that GrabPass is doing? I’m curious because I just assumed it essentially stalls the pipeline, hands over the framebuffer address to the current shader, the shader does its thing with it, and then it resumes the graphics pipeline for the remaining shaders, but from the “cost” of it described in the docs and in here, it sounds to me like it’s actually copying the entire framebuffer contents into a new texture. Is it actually copying the entire framebuffer into a texture? The Z-buffer, too?

I ask because I just want the framebuffer data (including Z-buffer) to use in rendering out a rather long, skinny quad after the opaque shaders are done rendering but before the transparency shaders have started rendering. Is GrabPass the right approach for this?

Thanks!

Most likely just copies the entire back buffer’s color buffer (RGBA) into an RGBA uncompressed texture. I don’t think it copies any extra buffers like depth or stencil etc.