So I had this thought about a way to re-create some effects not really used in games since Doom and Duke3D. They used am otherwise unique lighting method where things got darker as they were further away, which really helped add a nice mood of uncertainty to those games.
I remember trying to create such an effect with UDK, but I never quite got it right and went on to other things. I was thinking about it to today, and realized how it could be created.
I tried to build this shader, but I quickly found that I simply don’t know what I am doing. Honestly I’ve only dabbled a little bit with UE4 since it became free, so there’s a lot of its systems and changes that I am not very familiar with. While creating a material seems mostly the same, everything seems to have a new name and there are new options and stuff, and the more back-end stuff is really different, so I’m not sure where to look.
So I’m asking if someone can guide me through how to create this shader, so I can start experimenting to see how it would really look.
First of all, there are two fundamental qualities I need access to. One, I need an ability to retrieve a material’s lighting, but not actually apply the lighting to the material in the natural way, so I can run some processes on it and apply the final result manually. I’m not really sure what to call that, and I just hope I am describing it properly.
Second of all, I need to be able to use the distance from the camera. I remember in UDK I was playing around with a depth buffer, I think it was called. I’m not sure if that’s what I need again; if I recall correctly that feature only was useful for applying a material to the final render, the screen, not to an individual material in the world. I suppose this process could be applied to the screen, if it won’t cause problems with applying the lighting.
So anyway, for an individual texel or pixel, I would need the value of the lighting being applied to the surface. I would take the brightness, and then subtract ( clamped to not exceed 1.0 (the distance of that texel from the camera, times a given universal multiplier to set a “max distance from camera.”)) Next, I would have a lerp. I feel into the lerp the original texel value BEFORE any lighting is applied to it, and a universal color value, (presumably black, but you might want to change it out for other effects,) and for the alpha use the result from above: the (brightness - (clamp(distance * multiplier))). The result of this lerp would then be the final rendered pixel. Potentially I could even add the color/hue of the lighting back into it as well, but the lighting still would not get applied in the usual fashion, which thing I do not know how to do.
The end result of this is NOT the same as simply making a pixel darker if it is further from the camera. Objects that are brighter than others would stand out at greater distances, but being up close to both objects would allow them to be viewed clearly. No pixel would ever be brighter than the original texel value, but brightness can be adjusted to make some surfaces take greater distances to darken. It altogether creates an unnatural fog that makes the scene more unsettling, and can be used to add the same mysterious factor of darkness but without making something too dark to see.
I’d really like to see this effect using specific lighting sources and full 24-bit color.
So… How would I create this effect?