diff --git a/Assets/Shaders/SnapGrid3D.shader b/Assets/Shaders/SnapGrid3D.shader index a43ce07c0b..1c5984e3a0 100644 --- a/Assets/Shaders/SnapGrid3D.shader +++ b/Assets/Shaders/SnapGrid3D.shader @@ -1,4 +1,4 @@ -// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' +// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' // MIT License // // Copyright (c) 2020 fuqunaga @@ -148,16 +148,16 @@ Shader "Custom/Grid3D" float3 _Pointer_CS = mul(_WorldToCanvasMatrix, _Pointer_GS); float3 quantizedPointer_CS = float3( - round(_Pointer_CS.x / _GridInterval) * _GridInterval, - round(_Pointer_CS.y / _GridInterval) * _GridInterval, - round(_Pointer_CS.z / _GridInterval) * _GridInterval + round((_Pointer_CS.x + _GridInterval * 0.5) / _GridInterval) * _GridInterval, + round((_Pointer_CS.y + _GridInterval * 0.5) / _GridInterval) * _GridInterval, + round((_Pointer_CS.z + _GridInterval * 0.5) / _GridInterval) * _GridInterval ); float3 _CanvasOrigin_CS = mul(_WorldToCanvasMatrix, _CanvasOrigin_GS); float3 quantizedCanvasOrigin_CS = float3( - round(_CanvasOrigin_CS.x / _GridInterval) * _GridInterval, - round(_CanvasOrigin_CS.y / _GridInterval) * _GridInterval, - round(_CanvasOrigin_CS.z / _GridInterval) * _GridInterval + round((_CanvasOrigin_CS.x + _GridInterval * 0.5) / _GridInterval) * _GridInterval, + round((_CanvasOrigin_CS.y + _GridInterval * 0.5) / _GridInterval) * _GridInterval, + round((_CanvasOrigin_CS.z + _GridInterval * 0.5) / _GridInterval) * _GridInterval ); float3 canvasOffsetFix_CS = quantizedCanvasOrigin_CS - _CanvasOrigin_CS; float3 canvasOffsetFix_GS = mul(_CanvasToWorldMatrix, canvasOffsetFix_CS);