Garry's Mod Wiki

Revision Difference

render.PushCustomClipPlane#513095

<function name="PushCustomClipPlane" parent="render" type="libraryfunc">⤶ <description>⤶ Pushes a new clipping plane of the clip plane stack and sets it as active.⤶ ⤶ <note>A max of 2 clip planes are supported on Linux/POSIX, and 6 on Windows.</note>⤶ </description>⤶ <realm>Client</realm>⤶ <args>⤶ <arg name="normal" type="Vector">The normal of the clipping plane.</arg>⤶ <arg name="distance" type="number">The distance of the plane from the world origin. You can use &lt;page&gt;Vector:Dot&lt;/page&gt; between the normal and any point on the plane to find this, see [Example 1](/gmod/#Example).</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Clips the lower half of your custom entity</description>⤶ <code>⤶ function ENT:Draw()⤶ local normal = self:GetUp() -- Everything "behind" this normal will be clipped⤶ local position = normal:Dot( self:GetPos() ) -- self:GetPos() is the origin of the clipping plane⤶ ⤶ local oldEC = render.EnableClipping( true )⤶ render.PushCustomClipPlane( normal, position )⤶ ⤶ self:DrawModel()⤶ ⤶ render.PopCustomClipPlane()⤶ render.EnableClipping( oldEC )⤶ end⤶ </code>⤶ ⤶ </example>