# Sampling points of a nurbs surface using projections

I'm trying to sample a nurbs surface given certain constraints. Basically I'm trying to reproduce in 3D the following 2D situation. I don't know how to do this in 2D either so I need suggestions anyway.

The black curve would be my spline surface, the green line would be a plane above the surface. What I want to do is to shoot rays from the plane ortogonally, in equally spaced points, compute the intersections of such rays with the surfaces and store those points (the ones in the blue circle).

Is there a way to achieve this?

(I'm trying to emulate a depth map).

• Hello! Can I ask you more in details what do you mean when you say "store those points" ? Do you want to obtain a Python (numpy) array representation of those points, or you want a mesh made of quadrilateral faces, or something different? – Nicola Sap Sep 18 '18 at 13:17
• Ideally I'd like to have an image where each pixel stores the z coordinates, literally a depth map. I could sample the (u,v) coordinates but that wouldn't be the same thing. – user8469759 Sep 18 '18 at 13:19

## 1) Z-buffer (real depth map)

Place a camera above the surface

Set it to Ortographic. Then go in Camera view (Numpad 0) and change its Clipping values in such a way that they are the "tightest" possible to display all the curve (i.e. the biggest possible "Start" and the smallest possible "End")

Render the image (F12), then select "Z-Buffer" in the list of Channels below the render window:

This will give you an actual depth map.

## or 2) Z-dependent Emission color (faked depth map using Cycles)

Place your surface in a scene where the world is completely black and there are no lights. Use "Cycles" as the render engine.

Note down the minimum and the maximum "z" location (in my example, 0.1 and 0.9)

Assign a material that has the following node structure:

where in the Math nodes you'll use the values of min(z) and (max(z)-min(z)) noted down before, in my case 0.1 and 0.8.

Of course the colorRamp can be changed according to your needs.

This will color your surface with a different color according to its height:

.

Place an ortographic camera along the "z" axis (frame the surface from above) and render. The render will be a depth map

• Any chance you can attach the obj of your surface? So I can reproduce your example. – user8469759 Sep 18 '18 at 14:09
• sorry I've closed the file. however, it was just a Add>NURBS surface subdivided in edit mode and with a vertex pulled away. (May I ask you to avoid leaving multiple comments? The comment section is not for extended conversation. Thanks) – Nicola Sap Sep 18 '18 at 14:15
• Very last question, how do I save the depth map into a file (.png)? – user8469759 Sep 18 '18 at 15:19
• Unfortunately, the "easy" way is just to take a screenshot, as "Save as Image" will always export the full rendered picture (even if you have selected "Z-buffer"). The "clean" way is by using compositor "File Output" node as explained here: blender.stackexchange.com/questions/57972/… – Nicola Sap Sep 18 '18 at 15:28