Does TBG support bilinear filtering? ...and render-to-textures?
by John Klimek · in Torque Game Builder · 05/24/2007 (9:08 am) · 15 replies
Two quick (?) questions...
1) Does TGB support bilinear filtering? If so, how do I enable it?
2) Does TGB support rendering to a texture? If it's not supported in TorqueScript, how easy is it to implement in the source code? (I'm only a beginner at C++ and OpenGL)
In case you're wondering, the author of an excellent game e-mailed me back and explained how to achieve his "glowing line" effect. (see my thread here for more details: http://www.garagegames.com/mg/forums/result.thread.php?qt=62362)
Apparantly what he does is render his entire scene to a very small texture (128x128) and then draw it stretched over the scene multiple times at very low RGB levels with addidtive blending.
Also, is it possible to render the entire TGB screen a texture, filter it (as described above) and then draw it back to the screen? I would think it would be *much* harder to do this to the entire screen rather than creating a custom "glow" object or something.
Thanks for any help... :)
1) Does TGB support bilinear filtering? If so, how do I enable it?
2) Does TGB support rendering to a texture? If it's not supported in TorqueScript, how easy is it to implement in the source code? (I'm only a beginner at C++ and OpenGL)
In case you're wondering, the author of an excellent game e-mailed me back and explained how to achieve his "glowing line" effect. (see my thread here for more details: http://www.garagegames.com/mg/forums/result.thread.php?qt=62362)
Apparantly what he does is render his entire scene to a very small texture (128x128) and then draw it stretched over the scene multiple times at very low RGB levels with addidtive blending.
Also, is it possible to render the entire TGB screen a texture, filter it (as described above) and then draw it back to the screen? I would think it would be *much* harder to do this to the entire screen rather than creating a custom "glow" object or something.
Thanks for any help... :)
About the author
Recent Threads
#2
05/24/2007 (9:39 pm)
I think the latest versions of DirectX made it easier to render to texture than OpenGL. I tried to add DXT texture compression to TGB(T2D back then) a while back. It did work on the OGL side, but not DX... Hacking into the engine for this is not something I'd recommend...it's not easy. You will have to mess with the DLLs and extensions and etc. It's pretty hardcore. You'd probably spend less time and effort finding a way to fake it, or just doing something different instead.
#3
Since my goal is create glowing lines, I was thinking instead of rendering the entire scene to a texture, I could possibly create a new class such as t2dGlowLine and inside of that it will render a line to a texture and then shrink/stretch it back over itself to create a nice glowing line.
I would then to use this object to create all of my lines but it not be as hard as to do the whole screen at once?
05/25/2007 (4:39 am)
Are you saying it will be very hard to render the entire scene to texture or it will be very hard to render *anything* to a texture?Since my goal is create glowing lines, I was thinking instead of rendering the entire scene to a texture, I could possibly create a new class such as t2dGlowLine and inside of that it will render a line to a texture and then shrink/stretch it back over itself to create a nice glowing line.
I would then to use this object to create all of my lines but it not be as hard as to do the whole screen at once?
#4
05/25/2007 (8:34 am)
I know the engine supports taking screenshots (see game\demoGame.cc) but I don't think that method (using glReadPixels) would be fast enough to work for this effect in realtime. You would need to use pbuffers as Marc mentioned, and also make use of more OpenGL extensions. Why not try using pre-glowed lines? You may even be able to do something with the particle system here.
#5
Iny my other thread (see the link in the first post), people suggested using pre-rendered lines and other tricks so it looks like I may have to go that route. I was simply trying to duplicate an effect from another game (which used the shrink/stretch trick).
05/25/2007 (9:11 am)
Thanks for the reply...Iny my other thread (see the link in the first post), people suggested using pre-rendered lines and other tricks so it looks like I may have to go that route. I was simply trying to duplicate an effect from another game (which used the shrink/stretch trick).
#6
You can do this using pre-filtered images done in photoshop with some nice alpha and blending them in engine.
Basically some lines and copies of those lines gaussian blurred, etc.
The nice thing about blurring the scene in a texture is that you keep N frames worth of it and so get animated blurs which look really cool (although you can fake this with pre rendered stuff too).
05/25/2007 (9:45 am)
@John:You can do this using pre-filtered images done in photoshop with some nice alpha and blending them in engine.
Basically some lines and copies of those lines gaussian blurred, etc.
The nice thing about blurring the scene in a texture is that you keep N frames worth of it and so get animated blurs which look really cool (although you can fake this with pre rendered stuff too).
#7
Does TGB support the OpenGL FBO extension? (EXT_framebuffer_object)
(if not, is it hard to add support for this into the source?)
05/25/2007 (12:07 pm)
I may end up doing that...Does TGB support the OpenGL FBO extension? (EXT_framebuffer_object)
(if not, is it hard to add support for this into the source?)
#8
05/25/2007 (6:54 pm)
I don't believe TGB supports that extension.. and it would be pretty difficult to add to the source, even more so if you have to come up with a DirectX implementation as well. More trouble than it's worth lol. If I were you I wouldn't go touching those engine sources until you've exhausted the other ideas.
#9
Come to think of it have you had a look at DynamicTexture ( dgl/gDynamicTexture.cc )?
That does a full readback of the back buffer so might be a good place to start (if performance permits).
05/25/2007 (7:41 pm)
@John Klimek:Come to think of it have you had a look at DynamicTexture ( dgl/gDynamicTexture.cc )?
That does a full readback of the back buffer so might be a good place to start (if performance permits).
#10
05/25/2007 (8:03 pm)
Doh come to think of it theres the GuiEffectCanvas (gui/shiny/guiEffectCanvas.cc) that does a lot of that stuff too!
#11
be very careful of any technique that reads back from the video card itself. I'm honestly not sure if Neo's suggestion of reading the back buffer is implemented such that it takes the info from the card, or from memory, but in general modern video architecture penalizes you extremely in performance when you try to pull data from the card instead of pushing data to it.
To give some anecdotal backup to this: there was an extremely minor bug in early TSE (now TGE-A) code that did a sneaky little multiplication that turned out to force reading data from the video card. Once removed, performance increased an amazing amount (I don't have numbers, but we're talking 3-4 fold increase from one little change).
05/25/2007 (8:11 pm)
Quick word of advice (and I'm not following the technical details of the discussion extremely closely, so sorry if I'm off base):be very careful of any technique that reads back from the video card itself. I'm honestly not sure if Neo's suggestion of reading the back buffer is implemented such that it takes the info from the card, or from memory, but in general modern video architecture penalizes you extremely in performance when you try to pull data from the card instead of pushing data to it.
To give some anecdotal backup to this: there was an extremely minor bug in early TSE (now TGE-A) code that did a sneaky little multiplication that turned out to force reading data from the video card. Once removed, performance increased an amazing amount (I don't have numbers, but we're talking 3-4 fold increase from one little change).
#12
Yes I am indeed aware of the penalties imposed (and therefore the caveat above, although there are ways to amortize the cost of that read back over a set amount of time etc etc), and I I just wanted to add more options to explore.
05/25/2007 (8:25 pm)
@Stephen:Yes I am indeed aware of the penalties imposed (and therefore the caveat above, although there are ways to amortize the cost of that read back over a set amount of time etc etc), and I I just wanted to add more options to explore.
#13
I'll take a look into some of the above mentioned classes (eg. DynamicTexture, GuiEffectCanvas). I'll post again when I have more questions (which I'm sure will be soon) :)
Btw, Neo, I'm still looking forward to your isometric pack :)
05/25/2007 (8:26 pm)
Thanks for all of the advice everybody!I'll take a look into some of the above mentioned classes (eg. DynamicTexture, GuiEffectCanvas). I'll post again when I have more questions (which I'm sure will be soon) :)
Btw, Neo, I'm still looking forward to your isometric pack :)
#14
Heh, the iso builder is still going strong, I've got my mate Paul kicking away at it creating test maps etc and instructed him to be a total prima donna in requesting features and editing short cuts to make things easier for users. I will post new updates soon as I've tackled all the issues for the next milestone.
05/25/2007 (8:36 pm)
@John: Heh, the iso builder is still going strong, I've got my mate Paul kicking away at it creating test maps etc and instructed him to be a total prima donna in requesting features and editing short cuts to make things easier for users. I will post new updates soon as I've tackled all the issues for the next milestone.
#15
Thanks again for the help!!!
05/25/2007 (8:47 pm)
Excellent, I can't wait to see it! (perhaps you can release it to the GGTP group for testing when it's ready?) :)Thanks again for the help!!!
Torque 3D Owner Marc 'Dreamora' Schaerer
Gayasoft
2. No, it is not supported. If you implement it through C code, I would suggest looking for pbuffers for the opengl side and how to setup dynamic surfaces for rendering on them for the DX side.
On the last part: As mentioned in 2, no, its drawn to the backbuffer. you would need to implement that yourself. the filtering would happen on its own if it is enabled on the texture.
But you might need to understand the general opengl & dx behavior before stepping out and trying to add it.