- Home /
Combining RenderTextures for reflection
Hello!
In my game, I use the standard water asset that uses RenderTexture for the reflection. Now I want to reflect the clouds into the water. But the problem is, the cloud is rendered using secondary camera. Luckily, the cloud system happens to store its last frame as a RenderTexture. So I just "merge" that last frame into the reflection's RenderTexture using Graphic.Blit. The script looks like this:
Graphics.Blit(cloud.currentFrame, reflectCamera.targetTexture, Combiner);
"Combiner" is a material that uses the "Particles/Alpha Blended Premultiply" shader, it basically blends and removes black color from the cloud's frame, it works well enough for this purpose. So far, this is how it turns out:
(The reflection RenderTexture (the combining result) is at right bottom corner)
However, as you can see, I still have to "flip" the cloud's frame somehow right at the "horizon point".
How can I do that? How can I calculate/guess the horizon point/y-offset and flip the cloud frame based on that point and the main camera's pitch & roll angle (x & z-axis rotation)? Since the main camera is animated (i.e. when running).
I have second approach, which is to use another "flipped" helper camera to render the cloud and make a RenderTexture on its own. But the cloud is quite heavy, so rendering the cloud twice or more is a no-go for me.
Thanks in advance for any help!
Regards,
Just tagging :) @tomaszek