questions about render-to-texture

Started by MichaelJPCT, July 10, 2016, 04:43:22 PM

Previous topic - Next topic

MichaelJPCT

i am new to RTT, and i am now using FrameBuffer.setRenderTarget() to render into textures. (the FrameBuffer is the same one as the main window)

1) i blit white text into a texture after clearing FB with black color. when the texture is applied to a transparent Object3D, the black part is visible. but i have another texture loaded from a grayscale PNG file, where the black part is invisible. why isn't the RTT texture tranparent?
2) the doc says RTT must not use mipmaping. but if a texture will never be rendered into again after the first time, can it have mipmaping afterwards?
3) if a texture has size of 32x32 while the FB is 1280x800, when rendering into the texture, is the renderer doing work on 32x32 pixels or 1280x800 pixels? i mean the workload, is it small or large.

EgonOlsen


  • Because it has no alpha channel defined. If you load the texture that contains black parts, by default, the loader will generate an alpha channel that makes the black parts transparent. This isn't (it can't be) the case for render to texture. You would have to use a custom shader in some stage to make these parts transparent.
  • No, because mipmaps are generated on the client side, but the RTT exists on the server side (i.e. inside GPU memory)
  • 32*32. The FrameBuffer's size doesn't matter here.

MichaelJPCT

#2
for question 1 and 2 , i guess if i obtain all pixel data from the RTT texture and put into another texture , then the other texture would be the same as ordinary textures , right?

edit: i read the doc again and seems like there is no api that obtains pixel data from a RTT texture.

EgonOlsen

Yes, but it depends on how you "put it into another texture". If you are using on of the constructors that don't take the useAlpha parameter (or set it to false), then yes. If you set it via an ITextureEffect implementation, you have to provide alpha yourself.

EgonOlsen

...but then again: How you plan to obtain the actual pixel data of that texture? You would have to blit it into the FrameBuffer and grab the pixels from there, which is certainly doable but too slow for real-time. It should be fine, it you only do it once (or every now and then).

MichaelJPCT

i may create a software FB of small size when i need those effects.

MichaelJPCT

i have some more questions about RTT.
rtt is only stored in vram, can i call unloadTexture on a rtt texture?
can a rtt texture be freed in order to save vram?
if a rtt is freed from vram, will calling setRenderTarget re-create the rtt ?
if vram is full, what will happen if one more texture is needed for render?

EgonOlsen

Quote from: MichaelJPCT on August 31, 2016, 07:04:10 PM
rtt is only stored in vram, can i call unloadTexture on a rtt texture?
Yes, you can.
Quote from: MichaelJPCT on August 31, 2016, 07:04:10 PM
can a rtt texture be freed in order to save vram?
Yes. In the same way as any other texture. In fact, it is a normal texture, it's just used as a render target in addition to that.
Quote from: MichaelJPCT on August 31, 2016, 07:04:10 PM
if a rtt is freed from vram, will calling setRenderTarget re-create the rtt ?
Yes.
Quote from: MichaelJPCT on August 31, 2016, 07:04:10 PM
if vram is full, what will happen if one more texture is needed for render?
No idea. I guess it depends on the GPU and the drivers. Could be everything from a crash (most likely) to a white or undefined texture.