Basic setup for tessellation: mesh rendering
This commit is contained in:
parent
95f246bbd2
commit
3b97346ea7
@ -1,10 +1,14 @@
|
||||
#version 430
|
||||
|
||||
in vec3 position;
|
||||
in vec2 texture_coordinate;
|
||||
layout (location = 0) in vec3 position;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 2) in vec2 texture_coordinate;
|
||||
layout (location = 3) in vec3 aTangent;
|
||||
layout (location = 4) in vec3 aBitangent;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 projection_view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 view;
|
||||
|
||||
out PipelineData {
|
||||
vec4 position;
|
||||
@ -12,7 +16,7 @@ out PipelineData {
|
||||
} vs_out;
|
||||
|
||||
void main() {
|
||||
mat4 pvm = projection_view * model;
|
||||
mat4 pvm = projection * view * model;
|
||||
vs_out.texture_coordinate = texture_coordinate;
|
||||
vec4 homogenous_position = vec4(position, 1.0);
|
||||
vs_out.position = pvm * homogenous_position;
|
||||
|
@ -47,6 +47,14 @@ class FullDemo : public Gedeng::Application {
|
||||
mesh2.translate(glm::vec3(-3.0, 0.0, -3.0));
|
||||
mesh3.translate(glm::vec3(5.0, 0.0, 5.0));
|
||||
mesh3.rotate(45.0, glm::vec3(0.0, 1.0, 0.0));
|
||||
|
||||
terrain_mesh.translate(glm::vec3(0.0, 1.0, 0.0));
|
||||
|
||||
terrain_shader.add_vertex_shader("Shader/terrain.vs");
|
||||
terrain_shader.add_fragment_shader("Shader/terrain.fs");
|
||||
terrain_shader.add_tessellation_control_shader("Shader/terrain.tcs");
|
||||
terrain_shader.add_tessellation_evaluation_shader("Shader/terrain.tes");
|
||||
terrain_shader.link();
|
||||
}
|
||||
|
||||
~FullDemo() = default;
|
||||
@ -115,6 +123,12 @@ class FullDemo : public Gedeng::Application {
|
||||
mesh1.render(render_shader);
|
||||
mesh2.render(render_shader);
|
||||
mesh3.render(render_shader);
|
||||
|
||||
// Terrain
|
||||
terrain_shader.use();
|
||||
terrain_shader.setMat4("projection", camera.get_projection());
|
||||
terrain_shader.setMat4("view", camera.get_view());
|
||||
terrain_mesh.render_patches(terrain_shader);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -126,6 +140,7 @@ class FullDemo : public Gedeng::Application {
|
||||
|
||||
Gedeng::Shader render_shader;
|
||||
Gedeng::Shader debug_shader;
|
||||
Gedeng::Shader terrain_shader;
|
||||
|
||||
Gedeng::VertexBuffer vertex_rectangle;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user