angus Posted January 23, 2017 Posted January 23, 2017 I can't seem to figure out how to access the depth buffer in UUSL in my fragment shader. Is it possible to do? I want to get a Z value for a pixel
silent Posted January 24, 2017 Posted January 24, 2017 Hi Angus, Getting the depth buffer is depends on task that you are trying to achieve. If you are trying to read depth in deferred pass - it's not possible in DX11 / OpenGL render, you will get black texture. In Forward (Ambient pass) you can get access to the opacity depth buffer: opacity_depth texture. You can check the usage in unigine_particles.mat: <texture unit="11" type="opacity_depth" volume="1"/> and corresponding fragment shader (core/shaders/particles/fragment/ambient.frag): INIT_TEXTURE(11,TEX_DEPTH) For post processing you can get access to the current_depth (transparent + opacity depth) and opacity_depth textures. Simple reading from TEX_DEPTH texture will return native depth (as stored on GPU) in R channel. getLinearizedDepth(TEX_DEPTH, SCREEN_UV) will return depth in [0, far_plane] range and multiplying by s_depth_range.w will give you normalized depth in [0..1] interval (you can check this calculations in core/shaders/particles/fragment/ambient.frag shader). Thanks! 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts