zoukankan      html  css  js  c++  java
  • ue对 scene depth的封装

    SceneTexturesCommon.ush

    float LookupDeviceZ( float2 ScreenUV )
    {
    //mg_hack
    //return 1;
    #if	SCENE_TEXTURES_DISABLED
    	return FarDepthValue;
    #elif (POST_PROCESS_MATERIAL || POST_PROCESS_MATERIAL_MOBILE) && !POST_PROCESS_AR_PASSTHROUGH
    	#if MOBILE_DEFERRED_SHADING
    		return Texture2DSample(MobileSceneTextures.SceneDepthAuxTexture, MobileSceneTextures.SceneDepthAuxTextureSampler, ScreenUV).r;
    	#else
    		// SceneDepth texture is not accessible during post-processing as we discard it at the end of mobile BasePass
    		// instead fetch DeviceZ from SceneColor.A
    		return Texture2DSample(MobileSceneTextures.SceneColorTexture, MobileSceneTextures.SceneColorTextureSampler, ScreenUV).a;
    	#endif
    #elif COMPILER_GLSL_ES3_1 && PIXELSHADER
    	#if !OUTPUT_MOBILE_HDR
    		// Try framebuffer_fetch_depth_stencil to get the depth directly if the extension is available.
    		// We cannot fall back to fetching the alpha channel when MobileHDR=false because the alpha channel is only 8-bit.
    		return DepthbufferFetchES2();
    	#else
    		return FramebufferFetchES2().w;
    	#endif
    #elif VULKAN_SUBPASS_DEPTHFETCH && PIXELSHADER
    	// Special intrinsic to read from the current depth buffer
    	return VulkanSubpassDepthFetch();
    #elif (METAL_PROFILE && !MAC) && PIXELSHADER
    	return DepthbufferFetchES2();
    #else
    	// native Depth buffer lookup
    	return Texture2DSampleLevel(MobileSceneTextures.SceneDepthTexture, MobileSceneTextures.SceneDepthTextureSampler, ScreenUV, 0).r;
    #endif
    }
    
    /** Returns clip space W, which is world space distance along the View Z axis. Note if you need DeviceZ LookupDeviceZ() is the faster option */
    float CalcSceneDepth(float2 ScreenUV)
    {
    #if SCENE_TEXTURES_DISABLED
    	return SCENE_TEXTURES_DISABLED_SCENE_DEPTH_VALUE;
    #else
    	return ConvertFromDeviceZ(LookupDeviceZ(ScreenUV));
    #endif
    }
    

      

     

    CalcSceneDepth

    材质编辑器那边加的节点里面的代码是这个

    CalcSceneDepth

     

    相关节点有

    sceneDetph

    pixelDepth

    SceneTexture:SceneDepth

    DepthFade

    https://docs.unrealengine.com/en-US/RenderingAndGraphics/Materials/ExpressionReference/Depth/index.html

  • 相关阅读:
    财报就像一本故事书270页完整版本.pdf
    洛克菲勒留给儿子的38封信打包下载
    pip-20.2.3.tar.gz安装包下载
    python-3.8.6rc1-amd64.exe安装包下载
    apache-maven-3.6.3-bin.tar.gz 安装包下载
    中文拼音排序 element-ui的table web端实现
    vue中用axios下载后端的文档流(excel)
    git历史重写
    AMQP
    TODO
  • 原文地址:https://www.cnblogs.com/minggoddess/p/14532050.html
Copyright © 2011-2022 走看看