projects
/
ld42_outofspace
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tesselation as a function of distance
[ld42_outofspace]
/
sdr
/
field.tc.glsl
diff --git
a/sdr/field.tc.glsl
b/sdr/field.tc.glsl
index
71d6560
..
e742def
100644
(file)
--- a/
sdr/field.tc.glsl
+++ b/
sdr/field.tc.glsl
@@
-4,17
+4,23
@@
layout(vertices = 4) out;
uniform int tess_level;
uniform int tess_level;
+in float dist[gl_MaxPatchVertices];
+
void main()
{
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
gl_out[gl_InvocationID].gl_TexCoord[0] = gl_in[gl_InvocationID].gl_TexCoord[0];
gl_out[gl_InvocationID].gl_TexCoord[1] = gl_in[gl_InvocationID].gl_TexCoord[1];
void main()
{
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
gl_out[gl_InvocationID].gl_TexCoord[0] = gl_in[gl_InvocationID].gl_TexCoord[0];
gl_out[gl_InvocationID].gl_TexCoord[1] = gl_in[gl_InvocationID].gl_TexCoord[1];
- gl_TessLevelInner[0] = tess_level;
- gl_TessLevelInner[1] = tess_level;
+ const float min_tess_dist = 800.0;
+ float t = clamp(1.0 - dist[0] / min_tess_dist, 0.0, 1.0);
+ int tess = int(t * float(tess_level - 1.0)) + 1;
+
+ gl_TessLevelInner[0] = tess;
+ gl_TessLevelInner[1] = tess;
- gl_TessLevelOuter[0] = tess_level;
- gl_TessLevelOuter[1] = tess_level;
- gl_TessLevelOuter[2] = tess_level;
- gl_TessLevelOuter[3] = tess_level;
+ gl_TessLevelOuter[0] = tess;
+ gl_TessLevelOuter[1] = tess;
+ gl_TessLevelOuter[2] = tess;
+ gl_TessLevelOuter[3] = tess;
}
}