Need help on volumetric lighting

I have been learning to make shaders using glsl, and i came across a effect called Volumetric Lighting, or someone call it God Rays. When the method Radial Blur isn’t a perfect chose (The effect disappears when the sun is behind the camera), I tried another method: Get the Vertex Position of the Screen Space Pixel and form a ray with the Camera Position, loop through a certain amount of points inbetween the ray (like 100), and use the depth map to check if the point is directly visable to the light (the method of doing shadows), if so increment a variable. By dividing the result by 100 and do the following: pixelColor + vec4(1.0) * result. Supposingly white shift the pixel’s color. Yet it came into a huge error which brighten the entire side of the screen when my camera is looking at the positive x direction of the world, ofcoz no light ray is visable too. What is the problem? Can anyone address the error and tell me what did i do wrong? Thanks :slight_smile: