How it works...

The TCS takes the position and converts it to camera coordinates and stores the result in the p variable. The absolute value of the z coordinate is then scaled and clamped so that the result is between zero and one. If the z coordinate is equal to MaxDepth, the value of the depth will be 1.0, if it is equal to MinDepth, the depth will be 0.0. If z is between MinDepth and MaxDepth, the depth will get a value between zero and one. If z is outside that range, it will be clamped to 0.0 or 1.0 by the clamp function.

The value of depth is then used to linearly interpolate between MaxTessLevel and MinTessLevel using the mix function. The result (tessLevel) is used to set the inner and outer tessellation levels.

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.