www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: MichaelJPCT on July 10, 2016, 04:43:22 pm

Title: questions about render-to-texture
Post by: MichaelJPCT on July 10, 2016, 04:43:22 pm
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.
Title: Re: questions about render-to-texture
Post by: EgonOlsen on July 11, 2016, 08:37:16 am
Title: Re: questions about render-to-texture
Post by: MichaelJPCT on July 11, 2016, 10:14:06 am
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.
Title: Re: questions about render-to-texture
Post by: EgonOlsen on July 11, 2016, 11:06:28 am
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.
Title: Re: questions about render-to-texture
Post by: EgonOlsen on July 11, 2016, 11:08:18 am
...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).
Title: Re: questions about render-to-texture
Post by: MichaelJPCT on July 11, 2016, 01:47:55 pm
i may create a software FB of small size when i need those effects.
Title: Re: questions about render-to-texture
Post by: MichaelJPCT on August 31, 2016, 07:04:10 pm
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?
Title: Re: questions about render-to-texture
Post by: EgonOlsen on August 31, 2016, 08:18:26 pm
rtt is only stored in vram, can i call unloadTexture on a rtt texture?
Yes, you can.
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.
if a rtt is freed from vram, will calling setRenderTarget re-create the rtt ?
Yes.
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.