Hi Everyone,
It's been a while - I've been keeping myself busy with some less gratifying aspects to prevent me from playing too much with the unfinished product, then not knowing where to go next. I suppose we all learn as we go...
So a few years back, I was so sure I nailed (tesselation) shaders. Obviously, I had just gotten lucky.
I did things different back then - somehow I managed to get a 410 core tesselation shader working.
I'm already suspicious of my Shader Loader class, because I can't for the life of me find anything wrong with my shaders. I'll proceed to refactor my Shader Loader now, but perhaps I'll upload that if you agree that my shaders are OK, and that I'm not going crazy...
Vert
#version 410 core
in vec4 position;
in vec4 color;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
out vec4 position_tc_in;
out vec4 color_tc_in;
void main() {
position_tc_in = projection * view * model * position;
color_tc_in = color;
}
TesC
#version 410 core
in vec4 position_tc_in[];
out vec4 position_te_in[];
in vec4 color_tc_in[];
out vec4 color_te_in[];
layout (vertices = 4) out;
void main() {
position_te_in[gl_InvocationID] = position_tc_in[gl_InvocationID];
color_te_in[gl_InvocationID] = color_tc_in[gl_InvocationID];
if(gl_InvocationID == 0) {
gl_TessLevelOuter[0] = 4.0;
gl_TessLevelOuter[1] = 4.0;
gl_TessLevelOuter[2] = 4.0;
gl_TessLevelOuter[3] = 4.0;
gl_TessLevelInner[0] = 8.0;
gl_TessLevelInner[1] = 8.0;
}
}
TesE
#version 410 core
in vec4 position_te_in[];
in vec4 color_te_in[];
out vec4 color_f_in;
layout (quads) in;
void main() {
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
vec4 a = mix(position_te_in[1], position_te_in[0], u);
vec4 b = mix(position_te_in[2], position_te_in[3], u);
gl_Position = mix(a, b, v);
vec4 ca = mix(color_te_in[1], color_te_in[0], u);
vec4 cb = mix(color_te_in[2], color_te_in[3], u);
color_f_in = mix(ca, cb, v);
}
Frag
#version 410 core
in vec4 position_te_in[];
in vec4 color_te_in[];
out vec4 color_f_in;
layout (quads) in;
void main() {
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
vec4 a = mix(position_te_in[1], position_te_in[0], u);
vec4 b = mix(position_te_in[2], position_te_in[3], u);
gl_Position = mix(a, b, v);
vec4 ca = mix(color_te_in[1], color_te_in[0], u);
vec4 cb = mix(color_te_in[2], color_te_in[3], u);
color_f_in = mix(ca, cb, v);
}
The error
assets/shaders/terrain failed to link: Tessellation control info
-------------------------
0(23) : error C0000: syntax error, unexpected '[', expecting "::" at token "["
(0) : error C2003: incompatible options for link
This doesn't lead me to think the shader loading code is wrong, since it actually references a line in my tessellation shader. It's just that I don't think it's making a lot of sense. This is why I think my loader might be wrong, I just think it's really strange that everything here works if I remove the color part. I've spent a lot of time thinking it was the wrong way to pass a vertex attribute through the tessellation stages, but it doesn't really seem incorrect.
Many thanks in advance!
Best
- Svga