现在的位置: 首页 > 综合 > 正文

depth based tessalation (LOD)

2018年05月27日 ⁄ 综合 ⁄ 共 782字 ⁄ 字号 评论关闭
opengl4.0 shading 
TCS(tessa control shader) 
#version 400

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, MinTessLevel, depth);
gl_TessLevelOuter[0] = float(tessLevel);
gl_TessLevelOuter[1] = float(tessLevel);
gl_TessLevelOuter[2] = float(tessLevel);
gl_TessLevelOuter[3] = float(tessLevel);
gl_TessLevelInner[0] = float(tessLevel);
gl_TessLevelInner[1] = float(tessLevel);
gl_out[gl_InvocationID].gl_Position =
gl_in[gl_InvocationID].gl_Position;
}

抱歉!评论已关闭.