bool load_content() { // ********************************* // Create shadow map- use screen size shadow = shadow_map(renderer::get_screen_width(), renderer::get_screen_height()); // Create plane mesh meshes["plane"] = mesh(geometry_builder::create_plane()); // Create "teapot" mesh by loading in models/teapot.obj meshes["teapot"] = mesh(geometry("models/teapot.obj")); // Need to rotate the teapot on x by negative pi/2 meshes["teapot"].get_transform().rotate(vec3(-90.0, 0.0, 0.0)); // Scale the teapot - (0.1, 0.1, 0.1) meshes["teapot"].get_transform().scale = vec3(0.1,0.1,0.1); // *********************** // Set materials // - all emissive is black // - all specular is white // - all shininess is 25 // *********************** // White plane meshes["plane"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f)); meshes["plane"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f)); meshes["plane"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f)); meshes["plane"].get_material().set_shininess(25.0f); // Red teapot meshes["teapot"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f)); meshes["teapot"].get_material().set_diffuse(vec4(1.0f, 0.0f, 0.0f, 1.0f)); meshes["teapot"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f)); meshes["teapot"].get_material().set_shininess(25.0f); // ********************************* // Set spot properties // Pos (20, 30, 0), White // Direction (-1, -1, 0) normalized // 50 range, 10 power spot.set_position(vec3(20.0f, 30.0f, 0.0f)); spot.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f)); spot.set_direction(normalize(vec3(-1.0f, -1.0f, 0.0f))); spot.set_range(50.0f); spot.set_power(10.0f); // Load in shaders shadow_eff.add_shader("50_Spot_Light/spot.vert", GL_VERTEX_SHADER); shadow_eff.add_shader("50_Spot_Light/spot.frag", GL_FRAGMENT_SHADER); // Build effect shadow_eff.build(); // Set camera properties cam.set_position(vec3(0.0f, 20.0f, -30.0f)); cam.set_target(vec3(0.0f, 0.0f, 0.0f)); cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f); return true; }
bool load_content() { // ********************************* // Create shadow map- use screen size // Create plane mesh // Create "teapot" mesh by loading in models/teapot.obj // Need to rotate the teapot on x by negative pi/2 // Scale the teapot - (0.1, 0.1, 0.1) // ********************************* // Load texture tex = texture("textures/checker.png"); // *********************** // Set materials // - all emissive is black // - all specular is white // - all shininess is 25 // *********************** // White plane meshes["plane"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f)); meshes["plane"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f)); meshes["plane"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f)); meshes["plane"].get_material().set_shininess(25.0f); // Red teapot meshes["teapot"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f)); meshes["teapot"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f)); meshes["teapot"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f)); meshes["teapot"].get_material().set_shininess(25.0f); // ******************* // Set spot properties // ******************* // Pos (20, 30, 0), White // Direction (-1, -1, 0) normalized // 50 range, 10 power spot.set_position(vec3(30.0f, 20.0f, 0.0f)); spot.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f)); spot.set_direction(normalize(vec3(-1.0f, -1.0f, 0.0f))); spot.set_range(500.0f); spot.set_power(10.0f); // Load in shaders main_eff.add_shader("54_Shadowing/shadow.vert", GL_VERTEX_SHADER); vector<string> frag_shaders{"54_Shadowing/shadow.frag", "shaders/part_spot.frag", "shaders/part_shadow.frag"}; main_eff.add_shader(frag_shaders, GL_FRAGMENT_SHADER); shadow_eff.add_shader("50_Spot_Light/spot.vert", GL_VERTEX_SHADER); shadow_eff.add_shader("50_Spot_Light/spot.frag", GL_FRAGMENT_SHADER); // Build effects main_eff.build(); shadow_eff.build(); // Set camera properties cam.set_position(vec3(0.0f, 50.0f, -75.0f)); cam.set_target(vec3(0.0f, 0.0f, 0.0f)); cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f); return true; }