Game Development Community

Depth Of Field

by Westy · in Torque Game Engine Advanced · 09/15/2004 (1:39 pm) · 35 replies

Im looking at integrating a Depth Of Field shader to TSE. This woul dbe basically rendering a full screen quad and doing post processing. Any tips before i get too dirty?
Page «Previous 1 2
#1
01/31/2007 (9:02 am)
Any news about how setting Depth of field in TGEA ? :)
#2
02/01/2007 (4:48 pm)
Take a look at the GlowBuffer for how to set up something similar.
#3
02/10/2007 (7:43 pm)
Has anyone successfully implemented Depth of Field in their game? If so is there a tutorial or something around? Ive stared at the glow buffer script, but it didnt start talking to me or explaining how to make it work ;)

cheers

addikt
#4
02/13/2007 (6:54 pm)
The glowbuffer actually covers everything a Depth of Field shader would need. It shows how to use multiple render targets, which is really the key feature in Depth of Field.
#5
02/15/2007 (5:18 am)
I found a resource for fullscreen Nightvision and Heatvision shaders, unfortunately they dont compile properly...the main reason I downloaded it was to figure out how to apply Full Screen Shaders, does anyone know of any useful resources or tutorials to do this?

Ive got plenty of info on the shaders themselves, but how do you apply the full screen depth of field shader as an option?

Cheers

addikt
#6
02/15/2007 (6:30 am)
Have a pref that, if set on renders a quad with multiple render targets to the client?
#7
02/20/2007 (4:57 pm)
Does TGEA have anything like a Z buffer? in 3D and Visual effects we render out z depth passes and use them to fake depth of field.

Just a thought.
#8
02/20/2007 (7:00 pm)
I am pretty much illiterate when it comes to coding, but I have the shaders ready, and all I need to do is apply them as a full screen shader effect? How would I go about this?

I dont understand how the shader is initiated and how it is told to be applied as a fullscreen effect, any help is appreciated!

addikt
#9
02/21/2007 (7:30 am)
I would like to here the answer for this as well. I have seen where someone is working on a FOV shader maybe you could ask them as I'm sure it should be similar.

here this is prolly worth a read maybe contact the guy. let us know how it turns out. and share what you learn.

www.garagegames.com/mg/forums/result.thread.php?qt=36311
#10
02/21/2007 (5:32 pm)
There is a resource on this.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9104
Follow that properly and you'll have no problems.
#11
02/23/2007 (7:59 pm)
In regard to that Full Screen Shader Resource:

I'm receiving the following error on compile, Ive added the necessary edits to solve the other aformentioned errors, just this last one has me stumped. Help would be much appreciated ;)

gameTSCtrl.cpp
..\engine\game\gameTSCtrl.cpp(164) : error C3861: 'GameRenderFilters': identifier not found

addikt
#12
02/23/2007 (8:37 pm)
GameRenderFilters was removed in 1.0
#13
02/23/2007 (8:45 pm)
That explains why it doesnt work :( Does anyone know another way to get it working? Or can GameRenderFilters be put back in? Sorry Im not much of a coder and we are still looking for a lead coder for our project.

addikt
#14
02/24/2007 (12:38 am)
GameRenderFilters could easily be added back, but in most of the latest versions of TGEA it was basically an empty function that did nothing... so I would image you'd need to look elsewhere for the functionality needed
#15
02/24/2007 (1:51 am)
Well all I can say is if theres any Programmers who want to be involved in the development of a serious indi-RPG-Game, send me an email: addictive@ihug.co.nz

We have several coding 'projects' that require an experienced coder.

Thanks for the info anyway guys.

addikt

www.legendrpg.com
addiktive.proboards58.com/index.cgi
#16
02/28/2007 (2:51 am)
Well Ive finally got the FullScreen Shader effects working as per this thread: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9104

Thanks to Bryce and Matt. Im wondering if anyone has Depth of Field p&V.hlsl files setup and ready to go?

I've located some .fx shader files, but splitting them up hasnt worked...

addikt
#17
02/28/2007 (6:24 am)
I have nothing of actual DoF. However, I do have some simple blur shaders ripped from the ATI demos. (Not motion blur, static blur)

Pixel:

sampler RT: register(s0);
// Simple blur filter
struct v2f
{
   float4 Pos             : POSITION;
   float2 texCoord        : TEXCOORD0;
   float3 normal          : TEXCOORD1;
   float3 viewVec         : TEXCOORD2;
   float4 Pos2			  : TEXCOORD3;
   float4 Pos3			  : TEXCOORD4;
};

float4 main(v2f IN) : COLOR {

float sampleDist0 = 0.02;
float focus = 0.66;
float range = 0.60;

float2 samples[1] = {
   -0.326212, -0.405805,
   /*
   -0.840144, -0.073580,
   -0.695914,  0.457137,
   -0.203345,  0.620716,
    0.962340, -0.194983,
    0.473434, -0.480026,
    0.519456,  0.767022,
    0.185461, -0.893124,
    0.507431,  0.064425,
    0.896420,  0.412458,
   -0.321940, -0.932615,
   -0.791559, -0.597705,
   */
};

float2 blurAmt;
blurAmt.x = IN.Pos2.x / IN.Pos3.x;
blurAmt.y = IN.Pos2.y / IN.Pos3.y;

float4 sum = tex2D(RT, IN.texCoord);
   for (int i = 0; i < 1; i++){
      sum += tex2D(RT, IN.texCoord + sampleDist0 * samples[i] * blurAmt);
      }
      
      return sum / 3;


}

Vertex:

//-----------------------------------------------------------------------------
// Structures                                                                  
//-----------------------------------------------------------------------------
struct VS_OUTPUT
{
   float4 Pos             : POSITION;
   float2 texCoord        : TEXCOORD0;
   float3 normal          : TEXCOORD1;
   float3 viewVec         : TEXCOORD2;
   float4 Pos2			  : TEXCOORD3;
   float4 Pos3			  : TEXCOORD4;
};

//-----------------------------------------------------------------------------
// Main                                                                        
//-----------------------------------------------------------------------------
VS_OUTPUT main( VS_OUTPUT IN,
                  uniform float4x4 modelview       : register(C0)

)
{
   VS_OUTPUT OUT;

float3 distanceScale = 0.02;

   OUT.Pos = mul(modelview, IN.Pos);
   OUT.texCoord = IN.texCoord;
   OUT.Pos2 = IN.Pos * 10;
   OUT.Pos3 = IN.Pos * 20;
   // Eye-space lighting
   OUT.normal = mul(modelview, IN.normal);
   // We multiply with distance scale in the vertex shader
   // instead of the fragment shader to improve performance.
   OUT.viewVec = -distanceScale * mul(modelview, IN.Pos);
   return OUT;
}
#18
02/28/2007 (1:55 pm)
Awesome thanks for that Matt. The only thing is that it has a 2pixel wide line down the center of the screen ?

Im thinking I need to learn how to make shaders... hehe

addikt
#19
02/28/2007 (2:40 pm)
Hmm..I have not experienced this. Could you post a screenshot?
#20
02/28/2007 (3:58 pm)
Heres the screenie: img201.imageshack.us/img201/4999/blurshaderkf9.th.jpg

What Shader Version should I have it set as? Its currently on 2.0.

Im also testing a simple color shader, but I get some weird effects where the water will disappear with the shader on, sometimes, and changes based on color setting, also walking around the atlas terrain the shader will freak out and become black or a full color artifact.

I have a 7800GTX 512mb card with decent drivers, Im curious how you know what shader version to set for each shader? Is there something that determines which one to use?
Page «Previous 1 2