September 2018
Intermediate to advanced
472 pages
15h 36m
English
To create a shader program that varies the tessellation level based on the depth, use the following steps:
layout( vertices=16 ) out; uniform int MinTessLevel; uniform int MaxTessLevel; uniform float MaxDepth; uniform float MinDepth; uniform mat4 ModelViewMatrix; void main() { // Position in camera coordinates vec4 p = ModelViewMatrix * gl_in[gl_InvocationID].gl_Position; // "Distance" from camera scaled between 0 and 1 float depth = clamp( (abs(p.z) - MinDepth) / (MaxDepth - MinDepth), 0.0, 1.0 ); // Interpolate between min/max tess levels float tessLevel = mix(MaxTessLevel, ...Read now
Unlock full access