I’ve been trying to write a post-effect shader that applies fog to the 3dS Max window over other objects rendered.
I can make a post effect show up fine, and I’ve been able to sample the image that the scene has already rendered. I can’t seem to get a Depth Map though - I set up a sampler for it and it seems to be always filled with black.
Has anyone managed to sample the scene depth buffer from HLSL yet?
You can do it by using an environment shader in the scene effect loader.
I made an atmoshperic scattering post fx shader which works really fine in max, as long as there are no alpha textures in the scene.
Just fetch the rendertarget by using dxsas -> scriptexternal in the post shader.
Take a look at the simple_shadowmap.fx file. It helped me a lot.
Dont use fp rendertargets. They won’t work. Instead pack the values into a r16g16 or argb8 format.
If u have your own directx shader framework in max, you can use includes and calculate the fog in the vertex shader of each material. By using this method u won’t run into trouble when objects have an alpha texture.
Maybe there are some ways to readout the depth rendertarget that max uses already for the ssao implemention? I would love to know that This would solve all opacity problems in the env pass.