This document is negotiated by the actor, their representatives, and the production team, and within the rider are detailed descriptions of what the actor is willing to do on screen. SAG-AFTRA, the entertainment-industry labor union, designates a nudity rider as a requirement in contracts for roles that require 'nudity, partial nudity or simulated sex acts.' If you're seeing a naked actor on screen, it's important to know that legal contracts that outlined the details of the nudity were signed prior to the actor accepting the role.
For actors, filming a sex scene should never be a surprise.