Game Development Community

Fullscreen effects standard now?

by Ian Omroth Hardingham · in Torque Game Engine Advanced · 04/18/2008 (10:18 am) · 12 replies

Hey guys.

Just wondering if the full screen effect resource (or something functionally the same) is standard in 1.7 or if I need to add it in.

Ian

#1
04/18/2008 (10:40 am)
@Ian - If you check at the bottom of Frank's Resource (FS Shaders), I made a comment about this issue.

Frank's resource makes use of GFX member functions pushActiveRenderSurfaces(), setActiveRenderSurfaces(), and popActieRenderSurfaces(). With the release of TGEA 1.7, significant changes have been made to the GFX system. One such modification is that the ActiveRenderSurface calls have been eliminated (doh!). You will only find one reference to the deprecated calls: tsShapeInstance.cpp around line 903 and 933.

Now, TGEA 1.7 uses a RenderTarget system that is SIMILAR to the old rendering methods, but different enough to make the code conversion difficult for someone with awful rendering knowledge (like me).

So, I integrated Frank's resource. When I compiled, I went to the errors that were complaining about the renderSurfaces being invalid functions. There was another error, had something to do with getting screen coordinates...but I can't remember what it is until I get back to the code.

I did my best to swap the RenderSurface calls with RenderTarget. I managed to get a build to compile. When I ran the game and made the call to display a FS shader, it almost worked! The shader renders perfectly, but the Z-buffer is borked.
#2
04/27/2008 (5:56 am)
Michael,

I have the same problem here too pretty much. Rewrote the surface calls etc to use a GFXTextureTargetRef and attached the mSurface that was used originally to that. I assume you did the same or very similar. I also get the Z buffer problem.

I'm no graphics buff by any stretch of the imagination, but I'll have a nosey into this and see if I can figure it out.
#3
04/29/2008 (5:40 am)
Since I know longer have the time to do any coding, I have packaged the code I wrote back during beta. I've surrounded the code changes in comment blocks, so merging and visual inspection should be pretty painless. If anyone wants to get a hold of the code, just e-mail me at the address listed in my profile.

Only catch is if you find a solution, let me know so we can put a resource up for the community ASAP.
#4
04/29/2008 (5:46 am)
I had a look at Michaels code and everything looks to be correct regarding the depth buffer but again, I'm not an expert on TGEA GFX code either.
#5
05/18/2008 (6:19 am)
I'm currently porting my previous Pelorea code to TGEA 1.7.0. I will let you know as soon as I finish to merge the fullscreen shader code to TGEA 1.7.0.
#6
05/18/2008 (6:33 am)
Nice & thanks in advance Frank!
#7
05/18/2008 (12:46 pm)
Can you please post it as a resource when you're done?
Thanks in advance as well.
#8
05/18/2008 (4:24 pm)
Got it work yesterday night, with only an issue regarding DRL rendering which screw up everything. It seems it's because DRL is looking for a backbuffer... Will look at it this week, and hopefully solve it too so I can release the source code.
#9
05/20/2008 (8:43 am)
I found the issue with the DRL code. In fact, issue is regarding this line of code:
sgSurfaceChain[0]->readBackBuffer(corner);

Indeed, when we have a render texture target, the backbuffer is not correctly read. I have added a test to check if we are currently doing some fullscreenFx or not and depending on that I'm either trying to get the backbuffer, or initiate from a surface copy (in that case backbuf is your render texture target).
if(backBuf) sgSurfaceChain[0]->copyFromTexture(backBuf);
      else sgSurfaceChain[0]->readBackBuffer(corner);

and the code to copy from a surface.

bool GFXD3D9TextureObject::copyFromTexture( GFXTexHandle *tex )
{
   AssertFatal( mProfile->isRenderTarget(), "readBackBuffer: this texture is not a render target" );
   if ( !mProfile->isRenderTarget() )
      return false;

   GFXD3D9Device *device = dynamic_cast<GFXD3D9Device *>( mDevice );
   AssertFatal( device != NULL, "readBackBuffer: This is totally not a D3D9 device." );

   IDirect3DSurface9 *backBuffer;
   GFXD3D9TextureObject *d3dTex = static_cast<GFXD3D9TextureObject *>((GFXTextureObject*)(*tex));
   d3dTex->lock();
   if(!d3dTex) return false;
   d3dTex->get2DTex()->GetSurfaceLevel(0, &backBuffer);
   IDirect3DSurface9 *surf;

   get2DTex()->GetSurfaceLevel( 0, &surf );
   device->mD3DDevice->StretchRect( backBuffer, NULL, surf, NULL, D3DTEXF_NONE );

   surf->Release();
   backBuffer->Release();
   d3dTex->unlock();

   return true;
}

It works.... however I still have an issue as it is still buggy. It is flashing like if the texture is overwriting on itself many times. I will post a video of this issue soon.

Can someone give me a hint where I'm wrong? I will try them to correct it and post all the source code here.

Thanks
#10
05/20/2008 (5:11 pm)
Here is a video of the issue www.youtube.com/watch?v=iG2GRufde4g:
- first part you see the sepia tone shader active on the main gui, and working also with the guimodel viewer (showing solving of the depth buffer issue)
- second part, you see the effect with DLR / HDR rendereing active (flash) which in fact looks really like we are using many times the same picture and overwriting on it...

I'm sure in the code I call a GFX->Clear statement before anything... so the texture should be empty before rendering the scene.
#11
05/25/2008 (9:54 pm)
** bump **

Nobody can give my a hint why I have this flickering things. I figure out it is due of the chain texture initialization now... I will still dig in.

By the way, to have this half-way working, I did change the code for the backbuffer retrieval (inside DRL rendering), in order to copy from a texture when the rendertarget is not the window target but a texture target.
#12
05/25/2008 (10:02 pm)
Thanks for working on this Frank.
I'm looking forward to the resource.