1
\$\begingroup\$

I need to draw only a few specific objects into a texture (with their material) and then use that RenderTexture as a texture for an another object. I think Graphics.DrawMesh() and Graphics.SetRenderTarget() would be helpful, but I'm not sure.

Ultimately I'm trying to create refractive water, which will refract only specified GameObjects, not layers. How can I do this?

\$\endgroup\$
1
\$\begingroup\$

I'd probably use layers for this: put all objects that you want to reflect onto a 'Reflectable' layer. You can set the regular scene camera to render that layer like any other, but then you set the camera that renders your RenderTexture to only be able to see that layer.

\$\endgroup\$
1
  • \$\begingroup\$ Okay, it seems to be right. But if I have, for example two pools at the stage, then I have to draw both of them into each RenderTexture. So I will have a n^2 - n redundant draw calls, where n is the number of water planes. \$\endgroup\$
    – Netherwire
    Jul 20 '14 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.