It sounds like you're dealing with two common issues in fog rendering, likely in a game engine like Unity or Unreal. Let's break it down:
1. Fog Not Following Camera Angle (Only Look Position)
This usually happens when the fog is calculated in world space or view space, but not in screen space, and it's tied to the camera's forward vector or look direction, not its actual orientation.
Possible Causes & Fixes:
-
Fog shader uses Camera.main.transform.forward instead of actual view direction per pixel.
- ✅ Fix: Use the view ray or screen-space UVs to calculate fog based on the actual camera angle.
- In Unity (Shader Graph or HLSL), use the view direction node or
normalize(mul(unity_WorldToObject, float4(worldPos - _WorldSpaceCameraPos, 0))).
-
Fog is tied to a global height or distance, not per-pixel.
- ✅ Fix: Use depth-based fog (e.g., reconstruct world position from depth buffer and apply fog based on distance from camera).
2. Fog/Beams Get Pushed Back When Moving
This is a classic temporal reprojection or motion blur artifact, or it could be due to fog being calculated in a way that doesn't account for camera velocity.
Possible Causes & Fixes:
-
Fog is rendered in a separate pass that doesn’t respect camera motion.
- ✅ Fix: Ensure the fog is rendered in the opaque or transparent pass, not as a post-effect that lags behind.
-
Using TAA (Temporal Anti-Aliasing) or motion blur that affects the fog.
- ✅ Fix: Disable TAA/motion blur on the fog layer or use a velocity buffer to stabilize the fog.
-
Fog is tied to a world-space volume that doesn’t update fast enough.
- ✅ Fix: Use camera-relative rendering (common in Unity URP/HDRP or Unreal) to keep fog anchored to the camera.
Quick Unity-Specific Fixes (if using URP/HDRP):
- Use the built-in fog settings (Edit > Project Settings > Graphics > Fog) instead of custom shaders if possible.
- For volumetric fog, ensure "Volumetric Fog" is enabled in the Volume settings and tied to the camera's position.
- For custom shaders, use
UnityCG.cginc and ComputeScreenPos to get proper screen-space fog.
Quick Unreal-Specific Fixes:
- Use Exponential Height Fog and ensure "Volumetric Fog" is enabled.
- Check if the fog is tied to a Post Process Volume that moves with the camera.
- Disable "Temporal Upsampling" in the fog settings if it causes lag.
Debugging Tips:
- Visualize the depth buffer to see if fog is correctly aligned with the scene.
- Use a debug shader to output the fog factor as color and see how it changes when moving.
- Check if the fog is in a separate render pass that doesn’t update every frame.
If you can share whether you're using Unity, Unreal, or a custom engine, and whether this is volumetric fog, screen-space fog, or a shader-based effect, I can give more targeted advice.