Welcome, Guest.
Username: Password: Remember me

TOPIC: Fog/ mist shader?

Fog/ mist shader? 1 year 11 months ago #1

  • KTR2212
  • KTR2212's Avatar
  • Offline
  • Posts: 3
  • Thank you received: 1
I was wondering if it is possible to use information from the depthbuffer to create some sort of fog, mist or even a simulated atmosphere/ sky effect which all start from a certain radius from the player and all have different visual properties. (I have no idea how one would go about doing this, i'm not a coder but i'd love to know if it is possible).
The administrator has disabled public write access.
The following user(s) said Thank You: NattyDread

Fog/ mist shader? 1 year 11 months ago #2

  • NattyDread
  • NattyDread's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 85
+1
I just came here to request this also.
The administrator has disabled public write access.

Fog/ mist shader? 1 year 11 months ago #3

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2453
  • Thank you received: 1393
While volumetric fog, atmospheric scattering and all that can certainly be done as a post-processing effect (you can basicly raytrace everything, could even add new objects to the game) it requires to reconstruct the original positions for the objects in the scene.
For that you need a depthbuffer (which is there) and you need information about where the camera currently resides inside the game (translation, rotation, etc.) and the projection parameters (mostly field of view) or better the world/view/projection matrices. Those information cannot be obtained on a generic level, it's engine and game specific.
Now some (like field of view) could be just hardcoded in the shader, so that for each game one tries to find those values and sets them. Some are dynamic however (the camera position) and I can't think of a way to obtain these. One could try to simulate them by using keyboard and mouse input information to calculate an own position, but that would be highly inaccurate.

If somebody has a different idea, please share! =)
Cheers, crosire =)
Last Edit: 1 year 11 months ago by crosire.
The administrator has disabled public write access.

Fog/ mist shader? 1 year 11 months ago #4

  • NattyDread
  • NattyDread's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 85
Cant we just have a simple fog? Like, basically depth buffer using screen blending mode with a few options added. No atmospheric scattering, height fog, unreal 4 stuff.
You don't need camera position for DoF right? To my uneducated mind this looks so much like the DoF shader.
I would be happy with: fog color (near / far color as a plus); start distance (can go to negative values); end distance; opacity and that's it.
The administrator has disabled public write access.

Fog/ mist shader? 1 year 11 months ago #5

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2453
  • Thank you received: 1393
That of course should be pretty simple. Just add a fog color multiplied by the normalized depth value (so it's between 0 and 1, where 0 is the camera/near plane and 1 is the far plane) to the game output. Can't say how that looks though.
Cheers, crosire =)
The administrator has disabled public write access.

Fog/ mist shader? 1 year 11 months ago #6

  • Kleio420
  • Kleio420's Avatar
  • Offline
  • Posts: 217
  • Thank you received: 28
crosire wrote:
While volumetric fog, atmospheric scattering and all that can certainly be done as a post-processing effect (you can basicly raytrace everything, could even add new objects to the game) it requires to reconstruct the original positions for the objects in the scene.
For that you need a depthbuffer (which is there) and you need information about where the camera currently resides inside the game (translation, rotation, etc.) and the projection parameters (mostly field of view) or better the world/view/projection matrices. Those information cannot be obtained on a generic level, it's engine and game specific.
Now some (like field of view) could be just hardcoded in the shader, so that for each game one tries to find those values and sets them. Some are dynamic however (the camera position) and I can't think of a way to obtain these. One could try to simulate them by using keyboard and mouse input information to calculate an own position, but that would be highly inaccurate.

If somebody has a different idea, please share! =)
Could there not be some type of function down the road that could look for these values while the game is running to be dumped to be placed correctly instead of trying to guestimate the values ?
The administrator has disabled public write access.

Fog/ mist shader? 1 year 11 months ago #7

  • Nerd
  • Nerd's Avatar
  • Offline
  • Posts: 38
  • Thank you received: 5
This would be a really cool shader. I've always liked when I could crank up the fog in games so it would be really cool if you could generically apply it rather than actively modding since you'd have to have knowledge of the game beforehand to do that. Playing a brand new game with a bunch of fog applied to it could potentially make exploration a lot more interesting.
The administrator has disabled public write access.

Fog/ mist shader? 1 year 4 months ago #8

  • NattyDread
  • NattyDread's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 85
Can we get a bump on this?
Any chance on adding a defined axis fade (besides camera distance fade) so we can have something like height fog?
Last Edit: 1 year 4 months ago by NattyDread.
The administrator has disabled public write access.