   Depth of Field Simulation in GLSL
  I am a beginner concerning Shader Programming but I have the aim to simulate a depth of field effect in GLSL to use it in a games engine later on.There are a couple of approaches to this area... I thought it might be a good idea to render my 3D scene to a texture (renderable texture) in RenderMonkey first and then go on with the depth values which I send  from the vertex shader to the fragment shader. There is one approach to use the unused alpha channel to store the values but i don't really know how to do that?!It would be great if someone could tell me how to send the depth values from the vertex to the fragment shader.Furthermore if I am done with that I would like to use some blurring of the scene depending on the depth values.But I have already problems in declaring a blur filter:const vec4 samples[7] = {    0.0,    -3.0, 0,    1.0/64.0,    0.0,    -2.0, 0,    6.0/64.0,    0.0,    -1.0, 0,    15.0/64.0,    0.0,    0.0,    0,    20.0/64.0,    0.0,    1.0,    0,    15.0/64.0,    0.0,    2.0,    0,    6.0/64.0,    0.0,    3.0,  0,    1.0/64.0};..and get these compile errors:   COMPILE ERROR: API(OpenGL) /Effect Group 1/Effect1/Blur/Fragment Program/ (5): ERROR: 0:5: 'const 4-component vector of float' : cannot declare arrays of this type    COMPILE ERROR: API(OpenGL) /Effect Group 1/Effect1/Blur/Fragment Program/ (5): ERROR: 0:5: '=' : syntax error parse errorIs there another way in GLSL to declare a blur filter?Questions over questions. I would really appreciate any help on that subject!Thanks in advance!   
  Or is there a tutorial on that subject?   ;  I haven't done a DOF-shader myself, by I can tell you one thing; The z-value is easy :)Just pass the worldspace-position in a (varying) vec3 to the fragmentshader, and then access it as Vertex.z (assuming you named the vector "Vertex") - that'll give you the depth.   ;  like that:vertex shader:varying vec2 texCoord;varying vec3 vertex;void main(void){   vec2 Pos = sign(gl_Vertex.xy);   gl_Position = vec4(Pos.xy, 0, 1);   texCoord.x = 0.5 * (1.0 + Pos.x);   texCoord.y = 0.5 * (1.0 + Pos.y);    vertex = gl_Vertex.z;}fragment shader:uniform sampler2D RT;varying vec2 texCoord;varying vec3 vertex;void main(){ gl_FragColor = texture2D(RT, texCoord); }but how i am going to do the blurring? (the code is from my rendered-to-texture-scene to which i want to apply a blur somehow);  Not quite...In you vertexshader, you should have;vertex = vec3(gl_ModelViewMatrix * gl_Vertex);Then in you fragmentshader you can access the z-component (vertex.z).   ;  Oh... my bad!I'm just too busy here at work, so I'm jusk talking nonsensee.You should store your z-buffer in a texture also, that's what you need to do. I'm just gonna shut up for a while now :)   