Compare commits
No commits in common. "8162ca201e319cd6c98829f255b530a79e078015" and "163d413f9c4c751ade24f0fb3017b51a9158cf3a" have entirely different histories.
8162ca201e
...
163d413f9c
@ -59,4 +59,3 @@ testEnv.Program('test/bin/test-app.out', Glob('test/test-app/*.cpp'))
|
|||||||
testEnv.Program('test/bin/parallax-demo.out', Glob('test/parallax-demo/*.cpp'))
|
testEnv.Program('test/bin/parallax-demo.out', Glob('test/parallax-demo/*.cpp'))
|
||||||
testEnv.Program('test/bin/particle-demo.out', Glob('test/particle-demo/*.cpp'))
|
testEnv.Program('test/bin/particle-demo.out', Glob('test/particle-demo/*.cpp'))
|
||||||
testEnv.Program('test/bin/shadow-demo.out', Glob('test/shadow-demo/*.cpp'))
|
testEnv.Program('test/bin/shadow-demo.out', Glob('test/shadow-demo/*.cpp'))
|
||||||
testEnv.Program('test/bin/full-demo.out', Glob('test/full-demo/*.cpp'))
|
|
||||||
|
@ -133,6 +133,6 @@ void main() {
|
|||||||
float shadow = get_shadow(fs_in.FragPosLightSpace, normal);
|
float shadow = get_shadow(fs_in.FragPosLightSpace, normal);
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
FragColor = vec4(ambient + albedo + specular - shadow * 0.3, 1.0);
|
FragColor = vec4(ambient + albedo + specular - shadow * 0.25, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
in PipelineData {
|
|
||||||
vec4 position;
|
|
||||||
vec2 texture_coordinate;
|
|
||||||
} fs_in;
|
|
||||||
|
|
||||||
uniform sampler2D diffuse_texture;
|
|
||||||
|
|
||||||
out vec4 color;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
vec4 diffuse_texel = texture(diffuse_texture, fs_in.texture_coordinate);
|
|
||||||
color = vec4(1.0); // color = vec4(diffuse_texel);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout(vertices = 3) out;
|
|
||||||
|
|
||||||
in PipelineData {
|
|
||||||
vec4 position;
|
|
||||||
vec2 texture_coordinate;
|
|
||||||
} tc_in[];
|
|
||||||
|
|
||||||
out PipelineData {
|
|
||||||
vec4 position;
|
|
||||||
vec2 texture_coordinate;
|
|
||||||
} tc_out[];
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
tc_out[gl_InvocationID].texture_coordinate = tc_in[gl_InvocationID].texture_coordinate;
|
|
||||||
tc_out[gl_InvocationID].position = tc_in[gl_InvocationID].position;
|
|
||||||
|
|
||||||
gl_TessLevelInner[0] = 12;
|
|
||||||
gl_TessLevelOuter[0] = 12;
|
|
||||||
gl_TessLevelOuter[1] = 12;
|
|
||||||
gl_TessLevelOuter[2] = 12;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout(triangles) in;
|
|
||||||
|
|
||||||
in PipelineData {
|
|
||||||
vec4 position;
|
|
||||||
vec2 texture_coordinate;
|
|
||||||
} te_in[];
|
|
||||||
|
|
||||||
out PipelineData {
|
|
||||||
vec4 position;
|
|
||||||
vec2 texture_coordinate;
|
|
||||||
} te_out;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
te_out.texture_coordinate = gl_TessCoord.x * te_in[0].texture_coordinate;
|
|
||||||
te_out.texture_coordinate += gl_TessCoord.y * te_in[1].texture_coordinate;
|
|
||||||
te_out.texture_coordinate += gl_TessCoord.z * te_in[2].texture_coordinate;
|
|
||||||
|
|
||||||
te_out.position = gl_TessCoord.x * te_in[0].position;
|
|
||||||
te_out.position += gl_TessCoord.y * te_in[1].position;
|
|
||||||
te_out.position += gl_TessCoord.z * te_in[2].position;
|
|
||||||
|
|
||||||
gl_Position = te_out.position;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
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;
|
|
||||||
uniform mat4 view;
|
|
||||||
|
|
||||||
out PipelineData {
|
|
||||||
vec4 position;
|
|
||||||
vec2 texture_coordinate;
|
|
||||||
} vs_out;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
mat4 pvm = projection * view * model;
|
|
||||||
vs_out.texture_coordinate = texture_coordinate;
|
|
||||||
vec4 homogenous_position = vec4(position, 1.0);
|
|
||||||
vs_out.position = pvm * homogenous_position;
|
|
||||||
|
|
||||||
gl_Position = vs_out.position;
|
|
||||||
}
|
|
@ -110,16 +110,6 @@ class QuadMesh : public Mesh {
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_patches(Shader &shader) const {
|
|
||||||
shader.setMat4("model", get_matrix());
|
|
||||||
|
|
||||||
glPatchParameteri(GL_PATCH_VERTICES, 3);
|
|
||||||
|
|
||||||
glBindVertexArray(quadVAO);
|
|
||||||
glDrawArrays(GL_PATCHES, 0, 6);
|
|
||||||
glBindVertexArray(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int quadVAO = 0;
|
unsigned int quadVAO = 0;
|
||||||
unsigned int quadVBO;
|
unsigned int quadVBO;
|
||||||
|
@ -71,18 +71,6 @@ class Shader {
|
|||||||
glDeleteShader(shader);
|
glDeleteShader(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_tessellation_control_shader(const char *path) {
|
|
||||||
unsigned int shader = load_shader(path, GL_TESS_CONTROL_SHADER);
|
|
||||||
glAttachShader(ID, shader);
|
|
||||||
glDeleteShader(shader);
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_tessellation_evaluation_shader(const char *path) {
|
|
||||||
unsigned int shader = load_shader(path, GL_TESS_EVALUATION_SHADER);
|
|
||||||
glAttachShader(ID, shader);
|
|
||||||
glDeleteShader(shader);
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_transform_feedback(const char **varyings, size_t varying_count) {
|
void add_transform_feedback(const char **varyings, size_t varying_count) {
|
||||||
for (size_t i = 0; i < varying_count; i++) { // TODO: Is this loop required?
|
for (size_t i = 0; i < varying_count; i++) { // TODO: Is this loop required?
|
||||||
glTransformFeedbackVaryings(ID, varying_count, varyings, GL_INTERLEAVED_ATTRIBS);
|
glTransformFeedbackVaryings(ID, varying_count, varyings, GL_INTERLEAVED_ATTRIBS);
|
||||||
|
@ -1,172 +0,0 @@
|
|||||||
#include "Gedeng/DirectionalLight.h"
|
|
||||||
#include "Gedeng/Input.h"
|
|
||||||
#include "Gedeng/Logger.h"
|
|
||||||
#include "Gedeng/ObjMesh.h"
|
|
||||||
#include "Gedeng/ParticleSystem.h"
|
|
||||||
#include "Gedeng/QuadMesh.h"
|
|
||||||
#include "Gedeng/Shader.h"
|
|
||||||
#include "Gedeng/TextLabel.h"
|
|
||||||
#include "Gedeng/Vector3.h"
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#define GEDENG_MAIN
|
|
||||||
#include <Gedeng.h>
|
|
||||||
|
|
||||||
class FullDemo : public Gedeng::Application {
|
|
||||||
public:
|
|
||||||
FullDemo(unsigned long ms_per_update, unsigned int window_size_x, unsigned int window_size_y,
|
|
||||||
Gedeng::String window_name)
|
|
||||||
: Application(ms_per_update, window_size_x, window_size_y, window_name), particle_interval(0.2),
|
|
||||||
number_of_steps(10.0), number_of_refinement_steps(10.0), bump_depth(0.1),
|
|
||||||
render_shader(Gedeng::Shader("Shader/bump.vs", "Shader/bump.fs")),
|
|
||||||
debug_shader(Gedeng::Shader("Shader/depth-debug.vs", "Shader/depth-debug.fs")),
|
|
||||||
camera(Gedeng::FPSCamera(90, 1920, 1080, 0.1, 1000.0)),
|
|
||||||
albedo("Resources/Textures/PavingStones/PavingStones070_2K_Color.jpg", Gedeng::Texture::Settings()),
|
|
||||||
bump("Resources/Textures/PavingStones/PavingStones070_2K_Displacement.jpg", Gedeng::Texture::Settings()),
|
|
||||||
normal("Resources/Textures/PavingStones/PavingStones070_2K_Normal.jpg", Gedeng::Texture::Settings()),
|
|
||||||
particle_tex1("Resources/Textures/Particles/circle.png", Gedeng::Texture::Settings()),
|
|
||||||
particle_tex2("Resources/Textures/Particles/magic.png", Gedeng::Texture::Settings()),
|
|
||||||
particle_tex3("Resources/Textures/Particles/smoke.png", Gedeng::Texture::Settings()),
|
|
||||||
quad_mesh(Gedeng::QuadMesh(10.0)), light(glm::vec3(0.57735, -0.57735, 0.57735)),
|
|
||||||
mesh1("Resources/Meshes/Monkey.obj", Gedeng::ObjMesh::Settings()),
|
|
||||||
mesh2("Resources/Meshes/bench.obj", Gedeng::ObjMesh::Settings()),
|
|
||||||
mesh3("Resources/Meshes/ring.obj", Gedeng::ObjMesh::Settings()) {
|
|
||||||
particles.set_position(glm::vec3(0.0f, 0.0f, -10.0f));
|
|
||||||
particles.set_velocity(glm::vec3(-2, 4, -2), glm::vec3(2, 6, 2));
|
|
||||||
particles.set_gravity(glm::vec3(0, -4, 0));
|
|
||||||
particles.set_color(glm::vec3(0.0f, 0.5f, 1.0f));
|
|
||||||
particles.set_lifetime(1.0f, 1.5f);
|
|
||||||
particles.set_size(0.1);
|
|
||||||
particles.set_interval(particle_interval);
|
|
||||||
particles.set_number_of_particles(1);
|
|
||||||
particles.set_textures(&particle_tex1, &particle_tex2, &particle_tex3);
|
|
||||||
|
|
||||||
camera.translate(glm::vec3(0.0, 2.0, 1.0));
|
|
||||||
// camera.rotate(30, glm::vec3(1.0, 0.0, 0.0));
|
|
||||||
|
|
||||||
mesh1.translate(glm::vec3(2.0, 3.0, -2.0));
|
|
||||||
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;
|
|
||||||
|
|
||||||
void fixed_update(double delta) override {
|
|
||||||
camera.update(delta);
|
|
||||||
|
|
||||||
if (Gedeng::Input::is_mouse_down(GLFW_MOUSE_BUTTON_LEFT))
|
|
||||||
particles.set_position(camera.get_view_ray().get_plane_collision().collision_position);
|
|
||||||
|
|
||||||
if (Gedeng::Input::is_key_down(GLFW_KEY_2)) particle_interval = fmax(particle_interval + 0.1 * delta, 0.02);
|
|
||||||
if (Gedeng::Input::is_key_down(GLFW_KEY_1)) particle_interval = fmax(particle_interval - 0.1 * delta, 0.02);
|
|
||||||
|
|
||||||
particles.set_interval(particle_interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dynamic_update(double delta) override {
|
|
||||||
// Wireframe?
|
|
||||||
if (Gedeng::Input::is_key_down(GLFW_KEY_B)) {
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
||||||
} else {
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shadows
|
|
||||||
light.clear_shadows();
|
|
||||||
light.render_shadow(quad_mesh);
|
|
||||||
light.render_shadow(mesh1);
|
|
||||||
light.render_shadow(mesh2);
|
|
||||||
light.render_shadow(mesh3);
|
|
||||||
|
|
||||||
glViewport(0, 0, 1920, 1080);
|
|
||||||
glClearColor(0.1, 0.1f, 0.1, 1.0f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
render_shader.use();
|
|
||||||
|
|
||||||
// Camera
|
|
||||||
render_shader.setMat4("projection", camera.get_projection());
|
|
||||||
render_shader.setMat4("view", camera.get_view());
|
|
||||||
render_shader.setVec3("viewPos", camera.get_translation());
|
|
||||||
|
|
||||||
// Lighting
|
|
||||||
light.set_in_shader(render_shader);
|
|
||||||
|
|
||||||
render_shader.setFloat("number_of_steps", glm::max(0.0f, number_of_steps));
|
|
||||||
render_shader.setFloat("number_of_refinement_steps", glm::max(0.0f, number_of_refinement_steps));
|
|
||||||
render_shader.setFloat("bump_depth", glm::max(0.0f, bump_depth));
|
|
||||||
|
|
||||||
// Textures
|
|
||||||
albedo.bind_to(0);
|
|
||||||
normal.bind_to(1);
|
|
||||||
bump.bind_to(2);
|
|
||||||
light.bind_depth_map_to(3);
|
|
||||||
|
|
||||||
// Quad which is rendered onto
|
|
||||||
quad_mesh.render(render_shader);
|
|
||||||
|
|
||||||
// Particles
|
|
||||||
particles.set_camera(camera);
|
|
||||||
particles.update(delta);
|
|
||||||
particles.render();
|
|
||||||
|
|
||||||
// Props
|
|
||||||
render_shader.use();
|
|
||||||
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:
|
|
||||||
float particle_interval;
|
|
||||||
|
|
||||||
float number_of_steps;
|
|
||||||
float number_of_refinement_steps;
|
|
||||||
float bump_depth;
|
|
||||||
|
|
||||||
Gedeng::Shader render_shader;
|
|
||||||
Gedeng::Shader debug_shader;
|
|
||||||
Gedeng::Shader terrain_shader;
|
|
||||||
|
|
||||||
Gedeng::VertexBuffer vertex_rectangle;
|
|
||||||
|
|
||||||
Gedeng::FPSCamera camera;
|
|
||||||
|
|
||||||
Gedeng::Texture albedo;
|
|
||||||
Gedeng::Texture bump;
|
|
||||||
Gedeng::Texture normal;
|
|
||||||
|
|
||||||
Gedeng::Texture particle_tex1;
|
|
||||||
Gedeng::Texture particle_tex2;
|
|
||||||
Gedeng::Texture particle_tex3;
|
|
||||||
|
|
||||||
Gedeng::QuadMesh quad_mesh;
|
|
||||||
Gedeng::QuadMesh terrain_mesh;
|
|
||||||
|
|
||||||
Gedeng::ParticleSystem particles;
|
|
||||||
|
|
||||||
Gedeng::DirectionalLight light;
|
|
||||||
|
|
||||||
Gedeng::ObjMesh mesh1;
|
|
||||||
Gedeng::ObjMesh mesh2;
|
|
||||||
Gedeng::ObjMesh mesh3;
|
|
||||||
};
|
|
||||||
|
|
||||||
Gedeng::Application *Gedeng::create_application() {
|
|
||||||
GG_CLIENT_INFO("Creating Application");
|
|
||||||
return new FullDemo(20, 1920, 1080, String("Parallax Demo"));
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user