DGL https://delphigl.com/forum/ |
|
RenderToTexture + Transparency https://delphigl.com/forum/viewtopic.php?f=19&t=8361 |
Seite 1 von 1 |
Autor: | Stucuk [ Mo Apr 20, 2009 00:20 ] |
Betreff des Beitrags: | RenderToTexture + Transparency |
Im wondering if it is possible to have transparency when you render to a texture. I.E You render a cube which is solid, but every other pixel would be transparent. |
Autor: | Lossy eX [ Mo Apr 20, 2009 08:10 ] |
Betreff des Beitrags: | |
Depends on what kind of render to texture you are using? If you are using FrameBufferObjects i think its no problem. With pBuffers or normal copy from framebuffer you have to create an context with alphachannel. And you should verify this. The drivers have the right to ignore your wish. But i prefer the use of FrameBufferObjects. If its possible. Else you have to set the Alpha Paramater of the PixelFormatDescription while your contextcreation (CreateRenderingContext in the dglOpenGL.pas). After you have choosen your pixelformat you have to call DescribePixelformat and read all values of the fomat. If there is an alphavalue you have an alphachannel. If there isn't an alphavalue the driver ignores you. |
Autor: | Stucuk [ Di Apr 21, 2009 00:14 ] |
Betreff des Beitrags: | |
I assume FrameBufferObjects are cheaper to use than copying from the framebuffer? |
Autor: | Lossy eX [ Di Apr 21, 2009 07:55 ] |
Betreff des Beitrags: | |
Thats right. Because you have to attach real textures to the FBO. So OpenGL renders directly into textures and the workflow is much better for the asynchronous GPU. But FBOs has higher requirement for OpenGL. The first version of OpenGL they support FBOs in core is 3.0. Before you have to use the Extension GL_EXT_framebuffer_object. This is so around OpenGL 2.0. I think on moderate hardware this shouldn't be an problem. |
Autor: | Stucuk [ Di Apr 21, 2009 20:35 ] |
Betreff des Beitrags: | |
It would proberly be best if i implemented all 3 methods. My fathers ATI MOBILITY RADEON 7000 IGP (Which is the worst GFX card in my house) doesn't support FBO's but should support PBuffers. Intel cards iirc can't do pbuffers right even tho they have the extention. UFO Afterlight which iv helped maintain wouldn't work with intel cards due to the lack of WGL_ARB_pixel_format which iirc ment that a PBuffer couldn't be setup... Meh been months since i tryed to modify the code to allow Intel GFX cards to work(I don't have an Intel Card to test with). Well and having a 4th method that would come into effect if alpha channel failed to be setup. Note: Even if i wanted to use OpenGL 3 (Which i don't plan on doing until say 10 years down the line when all GFX Cards have OpenGL 3) my GFX Card is a Geforce 5900XT (You can all laugh now). |
Autor: | Lossy eX [ Mi Apr 22, 2009 09:26 ] |
Betreff des Beitrags: | |
I think it's not necessary to implement all three ways. It should be enough if you implement the classic copying from renderbuffer and the new version with FBOs. pBuffers are only a few better than copying from renderbuffer. But you have an seperate context and you need to activate him every time you wants to update the texture. So you have much more work and nearly no (or few) performance changes. And for copy from renderbuffer make sure you have activated the alphachannel and the driver listens to you. PS: I also dont plan to support OpenGL 3.0 in the next few years. It's not necessary for the projects i do. 3.0 is really overpowered for this. |
Autor: | Stucuk [ So Mai 17, 2009 17:31 ] |
Betreff des Beitrags: | |
Iv implemented FBO (Yep took a while for me to get round to it). Im just posting to note some things which GameDev.Net's FBO Tutorial which i used missed out(Incase anyone falls into the same problems). 1. When it comes to begining the FBO render you need to set the glclearcolor to have 0 for the Alpha or you don't get any transparency. (Granted the tutorial wasn't about transparent ones, tho it does use GL_RGBA for the texture) 2. You also have to call glClear after the glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, &fbo) call or the FBO's Texture will always remain black. Below is some code snipits from the texture class i made(It won't compile without modifications, like a header bit for the TTexture ![]() Code:
|
Seite 1 von 1 | Alle Zeiten sind UTC + 1 Stunde |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |