Render targets

Luomu
Posts: 58
Joined: Mon Jul 01, 2013 1:30 am

Render targets

Post by Luomu »

I managed to come up with a reasonably crossplatform rendertarget usage some time ago.

To start, you fill in a struct and request a RT from Renderer:

Code: Select all

RenderTargetDesc desc = {};
desc.width = 512;
desc.height = 512;
desc.TextureFormat = TEXTURE_RGB;
desc.DepthFormat = TEXTURE_DEPTH;

RenderTarget *sceneRt = renderer->CreateRenderTarget(desc);
Then you use the target:

Code: Select all

renderer->SetRenderTarget(sceneRt)
...draw some junk
renderer->SetRenderTarget(0);
Rendertarget contents may be now accessed:

Code: Select all

someMaterial->texture0 = sceneRt->GetColorTexture();
Pretty simple stuff. Now, the question #1 is, because there is nothing requiring this in the game right now, do I bother with making a pull request? In the future, RTT can be used for
- postprocessing (obv)
- dynamic textures (facegen or faction logo gen)
- fancy UI background blur
- generating ship silhouettes (for targeting info maybe? or a cool equip screen)

Question #2 is, can we make GL_Framebuffer_object a requirement? It really wasn't core until OpenGL 3, but the extension is very common. I have some gl extensions dumps from pioneer bug reports and fbos are always available.
robn
Posts: 302
Joined: Mon Jul 01, 2013 1:11 am
Location: Melbourne, Australia

Re: Render targets

Post by robn »

Luomu wrote:I managed to come up with a reasonably crossplatform rendertarget usage some time ago.
Seems pretty straightforward, I like it.
Now, the question #1 is, because there is nothing requiring this in the game right now, do I bother with making a pull request?
I think I'd be ok with it going in now. If it doesn't it'll end up bitrotting in a branch and nobody who hasn't read this will ever know it existed. If it goes in we can at least keep it compiling and make it easy for someone to try and use it somewhere.
Question #2 is, can we make GL_Framebuffer_object a requirement? It really wasn't core until OpenGL 3, but the extension is very common. I have some gl extensions dumps from pioneer bug reports and fbos are always available.
I'd be happy with that, though probably don't do it until we're actually using it. Maybe if we can't throw out the legacy renderer in one hit (well I would, but others disagree) we can do it a bit at a time.
FluffyFreak
Posts: 1343
Joined: Tue Jul 02, 2013 1:49 pm
Location: Beeston, Nottinghamshire, GB
Contact:

Re: Render targets

Post by FluffyFreak »

I say use it. Get it in and rendering all current content to a render target.

Q2: I think that most drivers implement it even for older cards as it was really just exposing functionality which was in DirectX for some time. So the hardwares been capable of it for a long time, OpenGL just took a while to agree the specifications etc.
Luomu
Posts: 58
Joined: Mon Jul 01, 2013 1:30 am

Re: Render targets

Post by Luomu »

Shadmar wrote:This is great, how hard will it be to hook up a postprocess shader to this?
It's very easy if you just want to get some results...

https://github.com/Luomu/pioneer/commit ... 3f884bcf18

"old TV pioneer"
Image

The real challenge, is as always to come up with a flexible architecture...
shadmar
Posts: 25
Joined: Mon Jul 01, 2013 7:28 pm

Re: Render targets

Post by shadmar »

Very nice.
Thanks!
FluffyFreak
Posts: 1343
Joined: Tue Jul 02, 2013 1:49 pm
Location: Beeston, Nottinghamshire, GB
Contact:

Re: Render targets

Post by FluffyFreak »

YAY! That's the sort of stuff I'm hoping to see :D
shadmar
Posts: 25
Joined: Mon Jul 01, 2013 7:28 pm

Re: Render targets

Post by shadmar »

Shader test
BlurX->BlurY->Bloom :

Image

Image

Image
TheBob
Posts: 76
Joined: Sat Jul 06, 2013 6:04 pm

Re: Render targets

Post by TheBob »

OMG!
FluffyFreak
Posts: 1343
Joined: Tue Jul 02, 2013 1:49 pm
Location: Beeston, Nottinghamshire, GB
Contact:

Re: Render targets

Post by FluffyFreak »

Alright, now radial blur and colour fade so there's a tinge of red around the border like you're going to black out :P

Nice work Luomu & Shadmar, looks like this might get a few pretty things quite quickly!
laarmen
Posts: 34
Joined: Fri Jul 05, 2013 8:49 am

Re: Render targets

Post by laarmen »

Are you sure we're playing the same game? oO
Post Reply