#include "BumpMapDemo.h" BumpMapDemo::BumpMapDemo() : height_scale(0.2), render_shader(Shader("Shader/bump.vs", "Shader/bump.fs")), camera(Camera(90, 1920, 1080, 0.1, 1000.0)), albedo("Resources/Textures/PavingStones/PavingStones070_2K_Color.jpg", Texture::Settings()), bump("Resources/Textures/PavingStones/PavingStones070_2K_Displacement.jpg", Texture::Settings()), normal("Resources/Textures/PavingStones/PavingStones070_2K_Normal.jpg", Texture::Settings()) { // Move and rotate the camera so we see the quad well camera.translate(glm::vec3(0.0, -1.0, 1.0)); camera.rotate(30, glm::vec3(1.0, 0.0, 0.0)); } void BumpMapDemo::render(float delta) { glClearColor(0.1f, 0.1f, 0.1f, 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 render_shader.setVec3("lightPos", glm::vec3(0.0, 1.0, 5.0)); // Settings for bump mapping render_shader.setFloat("height_scale", height_scale); // Textures albedo.bind_to(0); normal.bind_to(1); bump.bind_to(2); // Quad which is rendered onto quad_mesh.rotate(delta * 25.0f, glm::normalize(glm::vec3(0.0, 0.0, 1.0))); quad_mesh.render(render_shader); }