Jump to content
  • Advertisement
Sign in to follow this  

How do focal planes work?

This topic is 3194 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been looking into depth of field bluring and came across a demo where the scene image is taken and blurred, then it is re-combined with the un-blurred scene image based on its depth dot'd by a focal plane (a four dimensional vector). This is where it happens:
// Pixel Shader: DofCombine
// Desc: Combine the source image with the original image based on pixel
//       depths.
void DofCombine( float2 Tex : TEXCOORD0,
                 float2 Tex2 : TEXCOORD1,
                 out float4 oCol : COLOR0 )
    float3 ColorOrig = tex2D( g_samSceneColor, Tex2 );

    float3 ColorBlur = tex2D( g_samSrcColor, Tex );

    float Blur = dot( tex2D( g_samSrcPosition, Tex ), FocalPlane );

oCol = float4( lerp( ColorOrig, ColorBlur, saturate(abs(Blur)) ), 1.0f );

// Technique: PostProcess
// Desc: Performs post-processing effect that down-filters.
technique PostProcess
    string Parameter0 = "FocalPlane";
    float4 Parameter0Def = float4( 0.0f, 0.0f, 0.2f, -0.6f );
    int Parameter0Size = 4;
    string Parameter0Desc = " (vector of 4 floats)";
    pass p0
        VertexShader = null;
        PixelShader = compile ps_2_0 DofCombine();
        ZEnable = false;

Where g_samSceneColor is a sampler for the original scene and g_samSrcColor is the blurred image. What I don't understand is how FocalPlane works I'm also not sure what the first two components in it are used for, in the code above they're always 0,0, when I change them a strip appears through th escreen which has everything inside it properly focused, but I don't know what's going on. Just to add: What I'd really like to do is define a point of focus in the scene, say have four values such as x, y, z, w where x defines a minimum area where blur is applied full force and by the time x reaches y the blur dissapears, and then from z it starts going up again where it peeks again at w. It doesn't sound like something that should be too difficult but maybe it is?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!