Draw render target on itself ???

Is it possible to draw a render target on ITSELF? Like to make reflections.

That’s not that easy to answer actually … because of the way the GPU works. You cannot read from the rendertarget currently being rendered as that information is not yet in the rendertarget … (and even if it were, it would be different for every pixel processed) … so in the end the result would not be what you would expect to find.

I guess you talking about some water reflection in 2D as in 3D a reflection you would need a different view/perspective anyway … so in that case it should be totally fine to just use the output from the frame before, which you rendered to some texture before putting to screen (or do both at the same time)

You can’t read from a render target while writing to it, but you can always make a copy. Once you have a copy, you can read from one, while writing to the other.

Cool thanks. Just playing around with some ideas, yes for water reflections… But also surveillance screens that show feeds from remote cameras, and foreground crystals that distort stuff behind it…

-Trying to figure out an overall system to handle this sort of stuff. Will probably just switch rendertargets a few times, and construct my scene in slices, so reflections and such can be applied to appropriate layers.

Normally such things are handled by rendering a scene like it would be seen from a mirror - or a camera in your case. you render that to a texture and apply that texture to an object in the scene, which will then effectively display what the mirror (or the cam) would see.

and yes, that basically means running your whole scene rendering multiple times per frame

1 Like

Thats pretty good - render reflections FIRST, then render the scene…

See I was trying to render reflections and stuff INSIDE my normal render loop…

Reflections are expensive - the easy way is to just use a cubemap (the same which is used for the “background”/skycube) - and just use that to render a reflection. You can also just render a simpler version of the scene onto a cubemap and use that … it’s all a matter of how much performance you’re willed to sacrifice for pure esthetics.

Unfortunately, Raytracing isn’t common tech yet, once it is, developers no longer need to care about lighting & reflection anymore :slight_smile: