Thank you very much! I was experimenting with a much more complicated solution, but I guess using occludes will be more suitable (and actually work).
For testing this method I rendered my occlude mesh with a modified version of the “Unlit” shader, where I simply deleted the “oColor” definitions, so only “oDepth” will be written into, but nothing happens, the stuff behind the occlude is still visible. Is that the correct way to do it? (I don’t know much about hlsl shaders.)
Here is a part of the “PS” section of my hlsl shader: (The rest is identical to the standard “Unlit” shader)
#if defined(PREPASS)
// Fill light pre-pass G-Buffer
oColor = float4(0.5, 0.5, 0.5, 1.0);
oDepth = iWorldPos.w;
#elif defined(DEFERRED)
// Fill deferred G-buffer
//oColor = float4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
//oAlbedo = float4(0.0, 0.0, 0.0, 0.0);
//oNormal = float4(0.5, 0.5, 0.5, 1.0);
oDepth = iWorldPos.w;
#else
//oColor = float4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
#endif
EDIT: To elaborate: I now have two scenes and two viewports to first render the background and then the rest on top of it (like this). So I guess I need to have a shader where nothing except for the depth values is drawn, correct? If no color output occured, shouldn’t you be able to see the background viewport instead?