shader and viewer changes

This commit is contained in:
fruitstaa 2018-12-12 17:56:49 +01:00
parent 130c08f054
commit 6c2aaf897a
2 changed files with 9 additions and 9 deletions

View file

@ -32,22 +32,22 @@ void main()
vec2 instanced_pos = vec2(position.x + offset.x, position.z + offset.y); vec2 instanced_pos = vec2(position.x + offset.x, position.z + offset.y);
vec4 terrain_position = vec4(instanced_pos.x, getTerrainHeight(instanced_pos), instanced_pos.y, position.w); vec4 terrain_position = vec4(instanced_pos.x, getTerrainHeight(instanced_pos), instanced_pos.y, position.w);
/*
// read neightbor heights using an arbitrary small offset // read neightbor heights using an arbitrary small offset
vec3 off = vec3(1.0, 1.0, 0.0); vec3 off = vec3(1.0, 1.0, 0.0);
float hL = getTerrainHeight(position.xz - off.xz); float hL = getTerrainHeight(instanced_pos - off.xz);
float hR = getTerrainHeight(position.xz + off.xz); float hR = getTerrainHeight(instanced_pos + off.xz);
float hD = getTerrainHeight(position.xz - off.zy); float hD = getTerrainHeight(instanced_pos - off.zy);
float hU = getTerrainHeight(position.xz + off.zy); float hU = getTerrainHeight(instanced_pos + off.zy);
// deduce terrain normal // deduce terrain normal
n.x = hL - hR; n.x = hL - hR;
n.y = hD - hU; n.y = hD - hU;
n.z = 2.0; n.z = 2.0;
n = normalize(n); n = normalize(n);
*/
n = calculate_normal(terrain_position);
//n = calculate_normal(terrain_position);
//n = vec3(0.0, 1.0, 0.0); //n = vec3(0.0, 1.0, 0.0);
uv = vec2(terrain_position.x / 25.5, terrain_position.z / 25.5); uv = vec2(terrain_position.x / 25.5, terrain_position.z / 25.5);

View file

@ -387,7 +387,7 @@ void Viewer::drawContents()
glBindTexture(GL_TEXTURE_2D, roadColorTexture); glBindTexture(GL_TEXTURE_2D, roadColorTexture);
glUniform1i(road_texture_location, 3); glUniform1i(road_texture_location, 3);
/*
glActiveTexture(GL_TEXTURE4); glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, roadSpecularMap); glBindTexture(GL_TEXTURE_2D, roadSpecularMap);
glUniform1i(road_specular_location, 4); glUniform1i(road_specular_location, 4);
@ -395,7 +395,7 @@ void Viewer::drawContents()
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, roadNormalMap); glBindTexture(GL_TEXTURE_2D, roadNormalMap);
glUniform1i(road_specular_location, 5); glUniform1i(road_specular_location, 5);
*/
glDrawElementsInstanced(GL_TRIANGLE_STRIP, (PATCH_SIZE - 1) * PATCH_SIZE * 2, GL_UNSIGNED_INT, 0, instances.size()); glDrawElementsInstanced(GL_TRIANGLE_STRIP, (PATCH_SIZE - 1) * PATCH_SIZE * 2, GL_UNSIGNED_INT, 0, instances.size());