Create new scene. Create 2 intersected objects and lights, like this:
Create p_CSG shader. And assign it to both objects.
If you are using 3dsmax, you should create 'mental ray' material and assign p_CSG to 'Surface' slot
Create two shaders for A and B objects. For example mib_illum_phong or p_MegaTK
Connect these shaders to 'Color A' and 'Color B' of p_CSG shader
Open p_CSG property and set 'Object A' and 'Object B' field with name of your objects. For example "nurbsTorus1" and "nurbsSphere1"
If you are using 3dsmax you should add "|Instance(Mesh00)" to end of name of your object. For example "Torus01|Instance(Mesh00)" or "Sphere01|Instance(Mesh00)". Because 3dsmax rename all objects during export to *.mi. You may also export your scene to *.mi and find name of your objects in it
Render
Now we want get correct shadows... So, just enable it in your light (only raytrace shadow)
Go to Render Setting and set 'Shadow Method' to 'Segments'
Open Shading Group node of you p_CSG shader and assign same p_CSG shader to 'Shadow Shader' slot:
If you are using 3dsmax, open 'mental ray' material and copy p_CSG shader from 'Surface' slot to 'Shadow' with 'Instance' method
Render
Well done.
If you want add displacement to some object. You will need duplicate your p_CSG shader with 'With Connections to Network'. Please don't forget to connect p_CSG2 as shadow shader too
Assign new p_CSG shader to some object (for example torus)
Now we just need add displacement to p_CSG2SG node
Render