您当前的位置: 首页 >  unity

程序员正茂

暂无认证

  • 0浏览

    0关注

    283博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Unity Shader剖切管道隧道

程序员正茂 发布时间:2021-12-02 17:19:18 ,浏览量:0

CrossSection无法满足要求。

1.在section_clipping_CS.cginc新增_TubeLens,表示管道长度

#if CLIP_TUBES
	uniform float4 _AxisDirs[64];
	uniform float _TubeLens[64];//新增
#endif

2.修改裁剪代码

 

向量B=管道中心到该点的向量

向量A=_AxisDirs[i] * dot(_AxisDirs[i], posWorld - _centerPoints[i])  向量A为向量B管道轴线上的投影

向量C=posWorld - _centerPoints[i] -向量A 向量C为向量B在垂直于轴线平面上投影

		#if CLIP_TUBES
		bool _clipTubes = false;
		int _centerCountTruncated = min(_centerCount, 64);
		for (int i = 0; i < _centerCountTruncated; i++)
		{
			bool clip1 = ((dot(posWorld - _centerPoints[i] - _AxisDirs[i] * dot(_AxisDirs[i], posWorld - _centerPoints[i]),
				posWorld - _centerPoints[i] - _AxisDirs[i] * dot(_AxisDirs[i], posWorld - _centerPoints[i])) - _Radiuses[i] * _Radiuses[i]) < 0);
			bool clip2 = ((dot(_AxisDirs[i] * dot(_AxisDirs[i], posWorld - _centerPoints[i]), _AxisDirs[i] * dot(_AxisDirs[i], posWorld - _centerPoints[i])) - _TubeLens[i] * _TubeLens[i]) < 0);
			
			bool clip3 = clip1 && clip2;
			_clipTubes = _clipTubes || clip3;
		}

关注
打赏
1660743125
查看更多评论
立即登录/注册

微信扫码登录

0.0379s