Compare commits
No commits in common. "4cf0dc230be536094671b6c3fd70ecbe40144b5d" and "8162ca201e319cd6c98829f255b530a79e078015" have entirely different histories.
4cf0dc230b
...
8162ca201e
@ -5,11 +5,11 @@ in PipelineData {
|
|||||||
vec2 texture_coordinate;
|
vec2 texture_coordinate;
|
||||||
} fs_in;
|
} fs_in;
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D heightmap;
|
uniform sampler2D diffuse_texture;
|
||||||
|
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 diffuse_texel = texture(heightmap, fs_in.texture_coordinate);
|
vec4 diffuse_texel = texture(diffuse_texture, fs_in.texture_coordinate);
|
||||||
color = vec4(diffuse_texel);
|
color = vec4(1.0); // color = vec4(diffuse_texel);
|
||||||
}
|
}
|
@ -16,8 +16,8 @@ void main() {
|
|||||||
tc_out[gl_InvocationID].texture_coordinate = tc_in[gl_InvocationID].texture_coordinate;
|
tc_out[gl_InvocationID].texture_coordinate = tc_in[gl_InvocationID].texture_coordinate;
|
||||||
tc_out[gl_InvocationID].position = tc_in[gl_InvocationID].position;
|
tc_out[gl_InvocationID].position = tc_in[gl_InvocationID].position;
|
||||||
|
|
||||||
gl_TessLevelInner[0] = 32;
|
gl_TessLevelInner[0] = 12;
|
||||||
gl_TessLevelOuter[0] = 32;
|
gl_TessLevelOuter[0] = 12;
|
||||||
gl_TessLevelOuter[1] = 32;
|
gl_TessLevelOuter[1] = 12;
|
||||||
gl_TessLevelOuter[2] = 32;
|
gl_TessLevelOuter[2] = 12;
|
||||||
}
|
}
|
@ -2,12 +2,6 @@
|
|||||||
|
|
||||||
layout(triangles) in;
|
layout(triangles) in;
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D heightmap;
|
|
||||||
|
|
||||||
uniform mat4 model;
|
|
||||||
uniform mat4 projection;
|
|
||||||
uniform mat4 view;
|
|
||||||
|
|
||||||
in PipelineData {
|
in PipelineData {
|
||||||
vec4 position;
|
vec4 position;
|
||||||
vec2 texture_coordinate;
|
vec2 texture_coordinate;
|
||||||
@ -27,8 +21,5 @@ void main() {
|
|||||||
te_out.position += gl_TessCoord.y * te_in[1].position;
|
te_out.position += gl_TessCoord.y * te_in[1].position;
|
||||||
te_out.position += gl_TessCoord.z * te_in[2].position;
|
te_out.position += gl_TessCoord.z * te_in[2].position;
|
||||||
|
|
||||||
te_out.position.y += texture(heightmap, te_out.texture_coordinate).r;
|
gl_Position = te_out.position;
|
||||||
|
|
||||||
mat4 pvm = projection * view * model;
|
|
||||||
gl_Position = pvm * te_out.position;
|
|
||||||
}
|
}
|
@ -6,15 +6,20 @@ layout (location = 2) in vec2 texture_coordinate;
|
|||||||
layout (location = 3) in vec3 aTangent;
|
layout (location = 3) in vec3 aTangent;
|
||||||
layout (location = 4) in vec3 aBitangent;
|
layout (location = 4) in vec3 aBitangent;
|
||||||
|
|
||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 projection;
|
||||||
|
uniform mat4 view;
|
||||||
|
|
||||||
out PipelineData {
|
out PipelineData {
|
||||||
vec4 position;
|
vec4 position;
|
||||||
vec2 texture_coordinate;
|
vec2 texture_coordinate;
|
||||||
} vs_out;
|
} vs_out;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
mat4 pvm = projection * view * model;
|
||||||
vs_out.texture_coordinate = texture_coordinate;
|
vs_out.texture_coordinate = texture_coordinate;
|
||||||
vec4 homogenous_position = vec4(position, 1.0);
|
vec4 homogenous_position = vec4(position, 1.0);
|
||||||
vs_out.position = homogenous_position;
|
vs_out.position = pvm * homogenous_position;
|
||||||
|
|
||||||
gl_Position = vs_out.position;
|
gl_Position = vs_out.position;
|
||||||
}
|
}
|
@ -26,8 +26,7 @@ class FullDemo : public Gedeng::Application {
|
|||||||
particle_tex1("Resources/Textures/Particles/circle.png", Gedeng::Texture::Settings()),
|
particle_tex1("Resources/Textures/Particles/circle.png", Gedeng::Texture::Settings()),
|
||||||
particle_tex2("Resources/Textures/Particles/magic.png", Gedeng::Texture::Settings()),
|
particle_tex2("Resources/Textures/Particles/magic.png", Gedeng::Texture::Settings()),
|
||||||
particle_tex3("Resources/Textures/Particles/smoke.png", Gedeng::Texture::Settings()),
|
particle_tex3("Resources/Textures/Particles/smoke.png", Gedeng::Texture::Settings()),
|
||||||
heightmap("Resources/Textures/terrain.png", Gedeng::Texture::Settings()), quad_mesh(Gedeng::QuadMesh(10.0)),
|
quad_mesh(Gedeng::QuadMesh(10.0)), light(glm::vec3(0.57735, -0.57735, 0.57735)),
|
||||||
light(glm::vec3(0.57735, -0.57735, 0.57735)),
|
|
||||||
mesh1("Resources/Meshes/Monkey.obj", Gedeng::ObjMesh::Settings()),
|
mesh1("Resources/Meshes/Monkey.obj", Gedeng::ObjMesh::Settings()),
|
||||||
mesh2("Resources/Meshes/bench.obj", Gedeng::ObjMesh::Settings()),
|
mesh2("Resources/Meshes/bench.obj", Gedeng::ObjMesh::Settings()),
|
||||||
mesh3("Resources/Meshes/ring.obj", Gedeng::ObjMesh::Settings()) {
|
mesh3("Resources/Meshes/ring.obj", Gedeng::ObjMesh::Settings()) {
|
||||||
@ -127,13 +126,9 @@ class FullDemo : public Gedeng::Application {
|
|||||||
|
|
||||||
// Terrain
|
// Terrain
|
||||||
terrain_shader.use();
|
terrain_shader.use();
|
||||||
heightmap.bind_to(0);
|
|
||||||
terrain_shader.setMat4("projection", camera.get_projection());
|
terrain_shader.setMat4("projection", camera.get_projection());
|
||||||
terrain_shader.setMat4("view", camera.get_view());
|
terrain_shader.setMat4("view", camera.get_view());
|
||||||
terrain_mesh.render_patches(terrain_shader);
|
terrain_mesh.render_patches(terrain_shader);
|
||||||
|
|
||||||
// Log framerate
|
|
||||||
GG_CLIENT_INFO(std::string("Framerate: ") + std::to_string(1.0 / delta));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -159,8 +154,6 @@ class FullDemo : public Gedeng::Application {
|
|||||||
Gedeng::Texture particle_tex2;
|
Gedeng::Texture particle_tex2;
|
||||||
Gedeng::Texture particle_tex3;
|
Gedeng::Texture particle_tex3;
|
||||||
|
|
||||||
Gedeng::Texture heightmap;
|
|
||||||
|
|
||||||
Gedeng::QuadMesh quad_mesh;
|
Gedeng::QuadMesh quad_mesh;
|
||||||
Gedeng::QuadMesh terrain_mesh;
|
Gedeng::QuadMesh terrain_mesh;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user