Ejemplo n.º 1
0
bool render() {
  // Bind effect
  renderer::bind(eff);
  // Create MVP matrix
  auto M = m.get_transform().get_transform_matrix();
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                     1,                               // Number of values - 1 mat4
                     GL_FALSE,                        // Transpose the matrix?
                     value_ptr(MVP));                 // Pointer to matrix data

  // *********************************
  // Bind texture to renderer
  renderer::bind(tex, 1);
  // Set the texture value for the shader here
  glUniform1i(eff.get_uniform_location(" tex"), 0);
  // *********************************

  // Render the mesh
  renderer::render(m);

  return true;
}
Ejemplo n.º 2
0
bool render()
{
	// Bind effect
	renderer::bind(eff);
	// Create MVP matrix
	auto M = m.get_transform().get_transform_matrix();
	auto V = cam.get_view();
	auto P = cam.get_projection();
	auto MVP = P * V * M;
	// Set MVP matrix uniform
	glUniformMatrix4fv(
		eff.get_uniform_location("MVP"),
		1,
		GL_FALSE,
		value_ptr(MVP));

	// Bind and set texture
	renderer::bind(tex, 0);
	glUniform1i(eff.get_uniform_location("tex"), 0);

	// Render mesh
	renderer::render(m);

	return true;
}
bool render() {
  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Bind effect
    renderer::bind(eff);
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));

    // *********************************
    // Set material colour - all objects red
	glUniform4fv(eff.get_uniform_location("material_colour"), 1, value_ptr(vec4(1.0f, 0.0f, 0.0f, 1.0f)));
    // Set ambient intensity - (0.3, 0.3, 0.3, 1.0)
	glUniform4fv(eff.get_uniform_location("ambient_intensity"), 1, value_ptr(vec4(0.3f, 0.3f, 0.3f, 1.0)));
    // *********************************
    // Render mesh
    renderer::render(m);
  }

  return true;
}
Ejemplo n.º 4
0
bool render() {
  // Bind effect
  renderer::bind(eff);

  // Create MVP matrix
  auto M = m.get_transform().get_transform_matrix();
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;

  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                     1,                               // Number of values - 1 mat4
                     GL_FALSE,                        // Transpose the matrix?
                     value_ptr(MVP));                 // Pointer to matrix data

  // *********************************
  // Set the dissolve_factor uniform value

  // Bind the two textures - use different index for each


  // Set the uniform values for textures - use correct index


  // *********************************

  // Set UV_scroll uniform, adds cool movent (Protip: This is a super easy way to do fire effects;))
  glUniform2fv(eff.get_uniform_location("UV_SCROLL"), 1, value_ptr(uv_scroll));
  // Render the mesh
  renderer::render(m);

  return true;
}
Ejemplo n.º 5
0
bool render() {
  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Bind effect
    renderer::bind(eff);
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
    // *********************************
    // Set M matrix uniform
	glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(m.get_transform().get_transform_matrix()));
    // Set N matrix uniform - remember - 3x3 matrix
	glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_normal_matrix()));
    // Set material colour - specular material is white
	glUniform4fv(eff.get_uniform_location("material_colour"), 1, value_ptr(vec4(1.0f, 1.0f, 1.0f, 1.0f)));
    // Set shininess - Use 50.0f
	glUniform1f(eff.get_uniform_location("shininess"), 50.0f);
    // Set light colour - (1.0, 1.0, 1.0, 1.0)
	glUniform4fv(eff.get_uniform_location("light_colour"), 1, value_ptr(vec4(1.0f, 1.0f, 1.0f, 1.0f)));
    // Set light direction- (1.0, 1.0, -1.0)
	glUniform3fv(eff.get_uniform_location("light_dir"), 1, value_ptr(vec3(1.0f, 1.0f, -1.0f)));
    // Set eye position - Get this from active camera
	glUniform3fv(eff.get_uniform_location("eye_pos"), 1, value_ptr(vec3(cam.get_position())));
    // *********************************
    // Render mesh
    renderer::render(m);
  }

  return true;
}
Ejemplo n.º 6
0
bool render() {
  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Bind effect
    renderer::bind(eff);
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                       1,                               // Number of values - 1 mat4
                       GL_FALSE,                        // Transpose the matrix?
                       value_ptr(MVP));                 // Pointer to matrix data

    // *********************************
    // Set N matrix uniform - remember - 3x3 matrix
	glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_transform_matrix()));
    // Set material colour - all objects red
	glUniform4fv(eff.get_uniform_location("material_colour"), 1, value_ptr(vec4(1.0f, 0.0f, 0.0f, 1.0f)));
    // Set light colour- (1.0, 1.0, 1.0, 1.0)
	glUniform4fv(eff.get_uniform_location("light_colour"), 1, value_ptr(vec4(1.0f, 1.0f, 1.0f, 1.0f)));
    // Set light direction - (1.0, 1.0, -1.0)
	glUniform3fv(eff.get_uniform_location("light_dir"), 1, value_ptr(vec3(1.0f, 1.0f, -1.0f)));

    // *********************************
    // Render mesh
    renderer::render(m);
  }

  return true;
}
Ejemplo n.º 7
0
bool render() {
	// *********************************
	// Set render target to frame buffer
	renderer::set_render_target(frame);
	// Clear frame
	renderer::clear();
	// *********************************

	// Render meshes
	for (auto &e : meshes) {
		auto m = e.second;
		// Bind effect
		renderer::bind(eff);
		// Create MVP matrix
		auto M = m.get_transform().get_transform_matrix();
		auto V = cam.get_view();
		auto P = cam.get_projection();
		auto MVP = P * V * M;
		// Set MVP matrix uniform
		glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
		// Create MV matrix
		auto MV = V * M;
		// Set MV matrix uniform
		glUniformMatrix4fv(eff.get_uniform_location("MV"), 1, GL_FALSE, value_ptr(MV));
		// Set M matrix uniform
		glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
		// Set N matrix uniform
		glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_normal_matrix()));
		// Bind material
		renderer::bind(m.get_material(), "mat");
		// Bind light
		renderer::bind(light, "light");
		// Bind texture
		renderer::bind(tex, 0);
		// Set tex uniform
		glUniform1i(eff.get_uniform_location("tex"), 0);
		// Set eye position
		glUniform3fv(eff.get_uniform_location("eye_pos"), 1, value_ptr(cam.get_position()));
		// Render mesh
		renderer::render(m);
	}

	// *********************************
	// Set render target back to the screen
	renderer::set_render_target();
	// Bind Tex effect
	renderer::bind(tex_eff);
	// MVP is now the identity matrix
	auto MVP = glm::mat4();
	// Set MVP matrix uniform
	glUniformMatrix4fv(tex_eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
	// Bind texture from frame buffer
	renderer::bind(frame.get_frame(), 0);
	// Set the tex uniform
	glUniform1i(tex_eff.get_uniform_location("tex"), 0);
	// Render the screen quad
	renderer::render(screen_quad);
	// *********************************
	return true;
}
Ejemplo n.º 8
0
bool render() {
  // Bind effect
  renderer::bind(eff);
  // Create MVP matrix
  mat4 M = eulerAngleXZ(theta, rho);
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
  // Render geometry
  renderer::render(geom);
  return true;
}
Ejemplo n.º 9
0
bool render() {
  // Bind effect
  renderer::bind(eff);
  // Create MVP matrix
  mat4 M(1.0f);
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
  // *********************************
  // Render the mesh here
  renderer::render(m);
  // *********************************
  return true;
}
Ejemplo n.º 10
0
bool render() {
  // Bind effect
  renderer::bind(eff);
  // Create MVP matrix
  mat4 M(1.0f);
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                     1,                               // Number of values - 1 mat4
                     GL_FALSE,                        // Transpose the matrix?
                     value_ptr(MVP));                 // Pointer to matrix data
  // Render geometry
  renderer::render(geom);
  return true;
}
Ejemplo n.º 11
0
bool render() {
  // *********************************
  // Set render target to shadow map
	renderer::set_render_target(shadow);

  // Clear depth buffer bit
	glClear(GL_DEPTH_BUFFER_BIT);
  // Set render mode to cull face
	glCullFace(GL_FRONT);
  // *********************************

  // Bind shader
  renderer::bind(shadow_eff);

  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    // *********************************
    // View matrix taken from shadow map
	auto V = shadow.get_view();
    // *********************************

    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(shadow_eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
    // Render mesh
    renderer::render(m);


  }

  // *********************************
  // Set render target back to the screen
  renderer::set_render_target();
  // Set cull face to back
  glCullFace(GL_BACK);
  // *********************************

  return true;
}
Ejemplo n.º 12
0
bool render() {
  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Bind effect
    renderer::bind(eff);
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                       1,                               // Number of values - 1 mat4
                       GL_FALSE,                        // Transpose the matrix?
                       value_ptr(MVP));                 // Pointer to matrix data

    // *********************************
    // Set M matrix uniform
	glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
    // Set N matrix uniform - remember - 3x3 matrix
	glUniformMatrix3fv(eff.get_uniform_location("N"),
		1,
		GL_FALSE,
		value_ptr(m.get_transform().get_normal_matrix()));
    // Bind material
	renderer::bind(m.get_material(), "mat");
    // Bind light
	renderer::bind(light, "point");
    // Bind texture
	renderer::bind(tex, 0);
    // Set tex uniform
	glUniform1i(eff.get_uniform_location("tex"), 0);
    // Set eye position- Get this from active camera
	glUniform3fv(eff.get_uniform_location("eye_pos"), 1, value_ptr(cam.get_position()));
    // Render mesh
	renderer::render(m);

    // *********************************
  }

  return true;
}
Ejemplo n.º 13
0
bool render()
{
	// Bind effect
	renderer::bind(eff);
	// Create MVP matrix
	auto M = m.get_transform().get_transform_matrix();
	auto V = cam.get_view();
	auto P = cam.get_projection();
	auto MVP = P * V * M;
	// Set MVP matrix uniform
	glUniformMatrix4fv(
		eff.get_uniform_location("MVP"), // Location of uniform
		1, // Number of values - 1 mat4
		GL_FALSE, // Transpose the matrix?
		value_ptr(MVP)); // Pointer to matrix data

	// ******************************************************
	// Bind the three textures - use different index for each
	// ******************************************************

	renderer::bind(*texs[0], 0);
	renderer::bind(*texs[1], 1);
	renderer::bind(blend_map, 2); 

	// *******************************************************
	// Set the uniform values for textures - use correct index
	// *******************************************************

	
	glUniform1i(eff.get_uniform_location("tex[0]"), 0);
	glUniform1i(eff.get_uniform_location("tex[1]"), 1);
	glUniform1i(eff.get_uniform_location("blend"), 2);
    // ***************
	// Render the mesh
    // ***************
	renderer::render(m);


	return true;
}
Ejemplo n.º 14
0
bool render() {
  // Bind effect
  renderer::bind(eff);
  mat4 S, R, M;
  // *********************************
  // Create rotation matrix and scale matrix
  // Set M to be the combination of scale and rotation - make sure you have the correct order
  R = rotate(mat4(1.0f), theta, vec3(0.0f, 0.0f, 1.0f));
  S = scale(mat4(1.0f), vec3(s, s, s));
  M = R * S;

  // *********************************
  // Create MVP matrix
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
  // Render geometry
  renderer::render(geom);
  return true;
}
Ejemplo n.º 15
0
bool render() {
  // Bind effect
  renderer::bind(eff);
  // Create MVP matrix
  auto M = m.get_transform().get_transform_matrix();
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));

  // *********************************
  // Bind texture to renderer

  // Set the texture value for the shader here

  // *********************************

  // Render the mesh
  renderer::render(m);

  return true;
}
Ejemplo n.º 16
0
bool render() {
  // Bind effect
  renderer::bind(eff);
  mat4 T, R, S, M;
  // *********************************
  // Create transformation matrices
  // ******************************



  // Combine matrices to set M - remember multiplication order

  // *********************************
  // Create MVP matrix
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
  // Render geometry
  renderer::render(geom);
  return true;
}
Ejemplo n.º 17
0
bool render()
{
	mat4 M = eulerAngleXZ(theta, rho);
	auto V = cam.get_view();
	auto P = cam.get_projection();
	auto MVP = P * V * M;


	renderer::bind(eff);
	renderer::bind(tex, 0);

	// Set MVP matrix uniform
	glUniformMatrix4fv(
		eff.get_uniform_location("MVP"), // Location of uniform
		1, // Number of values - 1 mat4
		GL_FALSE, // Transpose the matrix?
		value_ptr(MVP)); // Pointer to matrix data



	glUniform1i(eff.get_uniform_location("tex"), 0);

	renderer::render(m);



#if 1
	renderer::bind(eff);
	renderer::bind(tex2, 1);
	glUniformMatrix4fv(
		eff.get_uniform_location("MVP"), // Location of uniform
		1, // Number of values - 1 mat4
		GL_FALSE, // Transpose the matrix?
		value_ptr(MVP)); // Pointer to matrix data

	glUniform1i(eff.get_uniform_location("tex"), 1);

	renderer::render(m2);
#endif
	// Bind effect
	
	// Create MVP matrix
	//auto M = m.get_transform().get_transform_matrix();

	//m.get_transform().rotate(angleAxis(theta, vec3(1, 0, 0)));
	//m.get_transform().rotate(angleAxis(rho, vec3(0, 1, 0)));

	// ************************
	// Bind texture to renderer
	// ************************
	//renderer::bind(tex, 0);
	//renderer::bind(tex2, 1);

	// *****************************************
	// Set the texture value for the shader here
	// *****************************************
	//glUniform1i(eff.get_uniform_location("tex"), 0);

	// Render the mesh


	return true;
}
Ejemplo n.º 18
0
bool render() {
  // *********************************
  // Set render target to shadow map

  // Clear depth buffer bit

  // Set render mode to cull face

  // *********************************

  // Bind shader
  renderer::bind(shadow_eff);

  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    // View matrix taken from shadow map

    // *********************************

    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(shadow_eff.get_uniform_location("MVP"), // Location of uniform
                       1,                                      // Number of values - 1 mat4
                       GL_FALSE,                               // Transpose the matrix?
                       value_ptr(MVP));                        // Pointer to matrix data
    // Render mesh
    renderer::render(m);
  }
  // *********************************
  // Set render target back to the screen

  // Set cull face to back

  // *********************************

  // Bind shader
  renderer::bind(main_eff);

  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(main_eff.get_uniform_location("MVP"), // Location of uniform
                       1,                                    // Number of values - 1 mat4
                       GL_FALSE,                             // Transpose the matrix?
                       value_ptr(MVP));                      // Pointer to matrix data
    // Set M matrix uniform
    glUniformMatrix4fv(main_eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
    // Set N matrix uniform
    glUniformMatrix3fv(main_eff.get_uniform_location("N"), 1, GL_FALSE,
                       value_ptr(m.get_transform().get_normal_matrix()));
    // *********************************
    // Set light transform





    // Bind material

    // Bind spot lights

    // Bind texture

    // Set tex uniform

    // Set eye position

    // Bind shadow map texture - use texture unit 1


    // Render mesh

    // *********************************
  }

  return true;
}