commit 2848cdbace72999a9e453f9f487ffdc8bb3d402e
parent 8e16948af4beb3b3f381d0d8e644915ff532777c
Author: William Casarin <jb55@jb55.com>
Date: Fri, 2 Nov 2018 02:21:47 -0700
i am baffled
Diffstat:
5 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/etc/shaders/terrain.tc.glsl b/etc/shaders/terrain.tc.glsl
@@ -2,11 +2,11 @@
layout(vertices = 3) out;
-in shader_data {
+in shader_datab {
#include shadervars.glsl
} vertex[];
-out shader_data {
+out shader_dataz {
#include shadervars.glsl
} tc_vertices[];
@@ -23,6 +23,7 @@ void main()
tc_vertices[gl_InvocationID].color_smooth = vertex[gl_InvocationID].color_smooth;
tc_vertices[gl_InvocationID].normal = vertex[gl_InvocationID].normal;
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
const float inner = 5.0;
const float outer = 8.0;
if (gl_InvocationID == 0) {
@@ -31,5 +32,4 @@ void main()
gl_TessLevelOuter[1] = outer;
gl_TessLevelOuter[2] = outer;
}
- gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
}
diff --git a/etc/shaders/terrain.te.glsl b/etc/shaders/terrain.te.glsl
@@ -2,7 +2,7 @@
layout(triangles, equal_spacing, cw) in;
-in shader_data {
+in shader_dataz {
#include shadervars.glsl
} tc_vertices[];
@@ -12,6 +12,7 @@ out shader_data {
#include uniforms.glsl
+
// out vec3 tePatchDistance = gl_TessCoord;
@@ -20,13 +21,13 @@ void main()
vertex.color = tc_vertices[0].color;
vertex.color_smooth = tc_vertices[0].color_smooth;
vertex.normal = tc_vertices[0].normal;
- vertex.shadow_coord = tc_vertices[0].shadow_coord;
+ vertex.shadow_coord = depth_mvp * tc_vertices[0].shadow_coord;
- vec4 p0 = gl_TessCoord.x * gl_in[0].gl_Position;
- vec4 p1 = gl_TessCoord.y * gl_in[1].gl_Position;
- vec4 p2 = gl_TessCoord.z * gl_in[2].gl_Position;
+ vec4 v = gl_TessCoord.x * gl_in[0].gl_Position;
+ + gl_TessCoord.y * gl_in[1].gl_Position;
+ + gl_TessCoord.z * gl_in[2].gl_Position;
// tePatchDistance = gl_TessCoord;
- vec4 te_position = normalize(p0 + p1 + p2);
- gl_Position = te_position;
+ vertex.frag_pos = (world * v).xyz;
+ gl_Position = mvp * v;
vertex.position = gl_Position.xyz;
}
diff --git a/etc/shaders/terrain.v.glsl b/etc/shaders/terrain.v.glsl
@@ -7,11 +7,10 @@ in vec3 normal;
#include uniforms.glsl
-out shader_data {
+out shader_datab {
#include shadervars.glsl
} vertex;
-
void main()
{
const int nlands = 6;
diff --git a/src/main.c b/src/main.c
@@ -36,7 +36,7 @@ int main(void)
int height = 480;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 4);
SDL_Window *window = SDL_CreateWindow(
"SDL2/OpenGL Demo", 0, 0, width, height,
diff --git a/src/render.c b/src/render.c
@@ -102,9 +102,12 @@ init_gl(struct resources *resources, int width, int height) {
resources->proj_persp);
/* Shader program */
+ /* struct shader *terrain_shaders[] = */
+ /* { &terrain_vertex, &fragment, &terrain_tc, &terrain_teval, */
+ /* &terrain_geom }; */
+
struct shader *terrain_shaders[] =
- { &terrain_vertex, &fragment, &terrain_tc, &terrain_teval,
- &terrain_geom };
+ { &terrain_vertex, &fragment, &terrain_tc, &terrain_teval };
/* struct shader *terrain_shaders[] = */
/* { &terrain_vertex, &fragment, &terrain_geom }; */