Be sure to use trilinear filtering, i.e. set min_filter to 
gl_linear_mipmap_linear.

/Marcus

Stefano wrote:
> Hi there OSGers!
> Here we are againg with my simple depth-of-field effect.. :P I grab the
> color buffer in a texture, i grab the depth buffer in another
> texture and then I simply use this fragment shader with a 
> polygonforeground
> to do the job:
>
> uniform sampler2D image;
> uniform sampler2D depth;
> uniform float threshold;
> uniform float maxAmount;
> uniform float depthBlur;
>
> void main(void) {
>  vec4 dd = texture2D(depth, gl_TexCoord[0].xy);
>  float x = (dd.r-threshold)/(1.0-threshold)*maxAmount;
>  gl_FragColor = texture2D(image, gl_TexCoord[0].xy, x);
> }
>
> * image and depth are obviously the color and the depth buffer
> textures.
> * threshold is just the starting z value from which i want DOF to be
> applied
> * maxAmount is the maximum mipmap i'll use with the deepest z value
>
> Everything works as it should, except for the x variable. It shoud be
> between 0 an maxAmount, which it is, and its changes should be smooth,
> as z values in the depth buffer smoothly change from point to point.
> Unfortunately what i'm getting is something very similar to a floor
> function, instead ( http://steffoz.altervista.org/1.png )
> The unexplicable thing is that the problem must be exactly in that
> line.. if I render the depth buffer with gl_FragColor = dd what I get
> is a smooth rendering ( http://steffoz.altervista.org/2.png ).. what is
> wrong?!
> I really can't find the reason for this behaviour.. any suggestions? I
> could attach some other screenshots to better describe the situation,
> if useful.
>
> Thank you very much,
> Stefano Verna
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to