Planar reflection clipplane bug on Metal.

1649 篇文章 11 订阅
1623 篇文章 22 订阅

Planar reflection clipplane bug on Metal.

0

It seems that Clip plane is not working on Metal. Both Mac and iOS is affected. Planar reflections incorrectly reflect objects that are wrong side of plane. I made simple test case project that clearly show how reflections are broken. alt text In screenshot there are multiple cones that reflect from underwater. When player look down first person weapon also behave incorrectly.

https://dl.dropboxusercontent.com/u/10960490/ClipPlaneBug.zip

Product Version:  UE 4.12
Tags: metal planar reflections
clipplanebug.png (2.4 MB)
more ▼

asked Jun 20 '16 at 3:47 PM

Jenny Gore gravatar image

Jenny Gore 
71  3  7


2 answers: sort voted first 
1

Unfortunately Planar Reflections are known to be broken on Metal in 4.12. They have been fixed upstream for OS X 10.11 (as always beta OSes are unsupported) and these changes will be part of binary 4.13. However if you are willing to work from source to modify MetalUtils.cpp and Common.usf they should work in 4.12:

Common.usf: Change:


         
         
  1. #define PLATFORM_SUPPORTS_GLOBAL_CLIP_PLANE (PS4_PROFILE || SM5_PROFILE || SM4_PROFILE)

To:


         
         
  1. #define PLATFORM_SUPPORTS_GLOBAL_CLIP_PLANE (PS4_PROFILE || SM5_PROFILE || SM4_PROFILE || METAL_PROFILE || METAL_MRT_PROFILE || METAL_SM4_PROFILE || METAL_SM5_PROFILE)
  2.  

MetalUtils.cpp: Change:


         
         
  1. /** Vertex shader system values. */
  2. static FSystemValue VertexSystemValueTable[] =
  3. {
  4. {"SV_VertexID", glsl_type::uint_type, "IN_VertexID", ir_var_in, "[[ vertex_id ]]"},
  5. {"SV_InstanceID", glsl_type::uint_type, "IN_InstanceID", ir_var_in, "[[ instance_id ]]"},
  6. {"SV_Position", glsl_type::vec4_type, "Position", ir_var_out, "[[ position ]]"},
  7. {"SV_RenderTargetArrayIndex", glsl_type::uint_type, "OUT_Layer", ir_var_out, "[[ render_target_array_index ]]"},
  8. {"SV_ClipDistance0", glsl_type::float_type, "ClipDistance0", ir_var_out, "[[ clip_distance ]]"},
  9. //#todo-rco: Values 1..7 are not really defined well in the Metal Language Doc...
  10. //{"SV_ClipDistance1", glsl_type::float_type, "ClipDistance1", ir_var_out, "[[ clip_distance ]]"},
  11. //{"SV_ClipDistance2", glsl_type::float_type, "ClipDistance2", ir_var_out, "[[ clip_distance ]]"},
  12. //{"SV_ClipDistance3", glsl_type::float_type, "ClipDistance3", ir_var_out, "[[ clip_distance ]]"},
  13. //{"SV_ClipDistance4", glsl_type::float_type, "ClipDistance4", ir_var_out, "[[ clip_distance ]]"},
  14. //{"SV_ClipDistance5", glsl_type::float_type, "ClipDistance5", ir_var_out, "[[ clip_distance ]]"},
  15. //{"SV_ClipDistance6", glsl_type::float_type, "ClipDistance6", ir_var_out, "[[ clip_distance ]]"},
  16. //{"SV_ClipDistance7", glsl_type::float_type, "ClipDistance7", ir_var_out, "[[ clip_distance ]]"},
  17. {NULL, NULL, NULL, ir_var_auto, nullptr}
  18. };
  19.  

To:


         
         
  1. /** Vertex shader system values. */
  2. static FSystemValue VertexSystemValueTable[] =
  3. {
  4. {"SV_VertexID", glsl_type::uint_type, "IN_VertexID", ir_var_in, "[[ vertex_id ]]"},
  5. {"SV_InstanceID", glsl_type::uint_type, "IN_InstanceID", ir_var_in, "[[ instance_id ]]"},
  6. {"SV_Position", glsl_type::vec4_type, "Position", ir_var_out, "[[ position ]]"},
  7. {"SV_RenderTargetArrayIndex", glsl_type::uint_type, "OUT_Layer", ir_var_out, "[[ render_target_array_index ]]"},
  8. {"SV_ClipDistance", glsl_type::float_type, "ClipDistance0", ir_var_out, "[[ clip_distance ]]"},
  9. {"SV_ClipDistance0", glsl_type::float_type, "ClipDistance0", ir_var_out, "[[ clip_distance ]]"},
  10. //#todo-rco: Values 1..7 are not really defined well in the Metal Language Doc...
  11. //#todo-marksatt: Perhaps not, but this is a semantic marker not a 'slot' so I think we can just use 0-8.
  12. {"SV_ClipDistance1", glsl_type::float_type, "ClipDistance1", ir_var_out, "[[ clip_distance ]]"},
  13. {"SV_ClipDistance2", glsl_type::float_type, "ClipDistance2", ir_var_out, "[[ clip_distance ]]"},
  14. {"SV_ClipDistance3", glsl_type::float_type, "ClipDistance3", ir_var_out, "[[ clip_distance ]]"},
  15. {"SV_ClipDistance4", glsl_type::float_type, "ClipDistance4", ir_var_out, "[[ clip_distance ]]"},
  16. {"SV_ClipDistance5", glsl_type::float_type, "ClipDistance5", ir_var_out, "[[ clip_distance ]]"},
  17. {"SV_ClipDistance6", glsl_type::float_type, "ClipDistance6", ir_var_out, "[[ clip_distance ]]"},
  18. {"SV_ClipDistance7", glsl_type::float_type, "ClipDistance7", ir_var_out, "[[ clip_distance ]]"},
  19. {NULL, NULL, NULL, ir_var_auto, nullptr}
  20. };
  21.  

Then rebuild ShaderCompileWorker & UE4 from Xcode.

more ▼
Newest

answered Jun 23 '16 at 1:52 AM

marksatt-pitbull gravatar image

marksatt-pitbull STAFF 
835  22  4  33

0

Hey Jenny Gore,

You actually are not using the full feature, as I did not see a Planar Reflection Actor placed within the scene. Try moving the floor down a little bit, and your reflections should render correctly. The placement of this plane as well as your floor is important, as it indicates where the objects contact the ground and create the reflections. The further up you move it, the more it will appear to clip the reflections of objects.

I downloaded and tested your project, and below are the results I deleted the floor mesh and placed a Planar Reflections actor in the appropriate location.

Planar Reflections Actor

alt text

Let me know if you have further questions or need additional assistance.

Cheers,

Andrew Hurley

snip20160620_2.png (712.4 kB)
more ▼

answered Jun 21 '16 at 2:04 AM

AndrewHurley gravatar image

AndrewHurley ♦♦ STAFF 
24.7k  394  16  291

Jenny Gore gravatar image  Jenny Gore  Jun 21 '16 at 4:16 AM

There is Planar Reflection Component within transparent Static mesh Actor that is just simple placeholder for water material. Same exact scene work fine on Windows. This is how project look on windows. alt textClip plane works correctly and cones are perfectly planar reflected to transparent mesh.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值