Hello everyone!
I’m trying to create fog of war feature in my project using postprocess shader. The first step is to calculate pixel position in world space using fragment and depth map and make this pixel black if it’s x and z coordinate in between 0 and 1 for example. It’s like a common topic as I searched the internet, but I had no luck to get working solution for it. Most commonly every thread stops on getting camera space coordinates of a fragment on camera near plane. I’ve spent a week trying to figure out how to implement my needs (to be honest I’m very new to computer graphics programming) and hasn’t done it so far.
Here is my playground with my best approach. The zone (volume) bounded by xyz coordinates in main if statement getting black, but if I rotate my camera it’s getting curved and moving.
The second issue I’ve got is when I create long zone along x coordinate it’s becoming curved dunno why. My best assumption that depth texture values is non-linearly distributed.
Thanks in advance, I will be grateful for any help.